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

  • Home
  • SEARCH
  • 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 5950621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:25:10+00:00 2026-05-22T17:25:10+00:00

I’ve got a problem. I use following regular expression: Pattern = (?’name’\w+(?:\w|\s)*), \s* (?’category’\w+(?:\w|\s)*),

  • 0

I’ve got a problem. I use following regular expression:


Pattern =
  (?'name'\w+(?:\w|\s)*), \s*
  (?'category'\w+(?:\w|\s)*), \s*
  (?:
      \{ \s*
          [yY]: (?'year'\d+), \s*
          [vV]: (?'volume'(?:([1-9][0-9]*\.?[0-9]*)|(\.[0-9]+))+), \s*
      \} \s*
      ,? \s*
  )*

with IgnorePatternWhitespaces option.
Everything seemed fine in my application until I debugged it & encountered a problem.


var Year = default(UInt32);
// ...
if((Match = Regex.Match(Line, Pattern, Options)).Success)
{
    // Getting Product header information
    Name = Match.Groups["name"].Value;

    // Gathering Product statistics
    for(var ix = default(Int32); ix < Match.Groups["year"].Captures.Count; ix++)
    {
       // never get here
       Year = UInt32.Parse(Match.Groups["year"].Captures[ix].Value, NumberType, Culture);
    }
}

So in the code above.. In my case Match is always successful. I get proper value for Name but when turn comes to for loop program flow just passes it by. I debugged there’s no Captures in Match.Groups["year"]. So it is logical behavior. But not obvious to me where I’m wrong. Help!!

There is a previous connected post Extract number values enclosed inside curly brackets I made.

Thanks!

EDIT. Input Samples

Sherwood, reciever, {y:2008,V:5528.35}, {y:2009,V:8653.89}, {y:2010, V:4290.51}
  • I need to capture 2008, 5528.35, 2009, 8653.89, 2010, 4290.51 values and operate with them as named groups.

2D EDIT

I tried using ExplicitCapture Option and following expression:

(?<name>\w+(w\| )*), (?<category>\w+(w\| )*), (\{[yY]:(?<year>\d+), *[vV]:(?<volume>(([1-9][0-9]*\.?[0-9]*)|(\.[0-9]+))+)\}(, )?)+

But that didn’t help.

  • 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-22T17:25:11+00:00Added an answer on May 22, 2026 at 5:25 pm

    Edit: You could simplify by matching everything until the next comma: [^,]*. Here’s a full code snippet to match your source data:

    var testRegex = new Regex(@"
        (?'name'[^,]*),\s*
        (?'category'[^,]*),\s*
        ({y:(?'year'[^,]*),\s*
        V:(?'volume'[^,]*),?\s*)*",
        RegexOptions.IgnorePatternWhitespace);
    var testMatches = testRegex.Matches(
        "Sherwood, reciev, {y:2008,V:5528.35}, {y:2009,V:8653.89}, {y:2010, V:4290.51}");
    foreach (Match testMatch in testMatches)
    {
        Console.WriteLine("Name = {0}", testMatch.Groups["name"].Value);
        foreach (var capture in testMatch.Groups["year"].Captures)
            Console.WriteLine("    Year = {0}", capture);
    }
    

    This prints:

    Name = Sherwood
        Year = 2008
        Year = 2009
        Year = 2010
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.