Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6701243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:54:38+00:00 2026-05-26T06:54:38+00:00

I suck at Regex’s and am surprised I was able to get as far

  • 0

I suck at Regex’s and am surprised I was able to get as far as I did by myself.

So far I’ve got this:

string text = "Whoa here is some very cool text.<phone>222-222-5555</phone><timesCalled>6</timescalled>";

Regex phoneRegex = new Regex(@"<phone>(.*?)<\/phone>");
Regex calledRegex = new Regex(@"<timesCalled>(.*?)<\/timesCalled>");
string phone = phoneRegex.Match(text).Value;
string timesCalled = calledRegex.Match(text).Value;

Both of these give me the full tags and the value inside, how do I make it so it only returns what is inside the tag? Also I need a final regex that would return all the text not inside those tags, so Whoa here is some very cool text. from the above example. The special tags would always appear after the normal text, if that matters.

Edit: Thanks for the answers all, I still need the final regex though (bolded above).

So far I tried this:

 string pattern = @"^" + phoneRegex.Match(text).Value + calledRegex.Match(text).Value;
 Regex textRegex = new Regex(pattern);
 string normalText = textRegex.Match(text).Groups[1].Value;

but that is returning nothing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:54:39+00:00Added an answer on May 26, 2026 at 6:54 am

    You want to get the value of the group:

    calledregex.Match(text).Groups[1].Value
    

    Groups are 1-based.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I suck at regex, I only managed to get so far preg_match(/http:\/\//, $url) .
Possible Duplicate: How can I get a regex to check that a string only
Have not done this before, so obviously I suck at it. Here 64 pixels
First, let me say this: I suck at regex and htaccess. I'm trying to
So I get suck of thoose flags and byte operations so here is the
Guys I hate Regex and I suck at writing. I have a string that
Okey I got two questions. Number one. I really suck at regex, it just
The regex [a-z0-9]{1,10}_([0]?[1-9]|[1][0-2])([0]?[1-9]|[1|2][0-9]|[3][0|1])([2000-2099]{4}).cta$ This string fails abscriprod_01152013.cta This string works abscriprod_11152012.cta It appears that
I suck at php, and cant find the error here. The script gets 2
My current solution will suck sometimes EDIT For those who don't understand,see this example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.