Results 1 to 3 of 3

Thread: Regex Problem[Resolved by pax]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    Regex Problem[Resolved by pax]

    It seems that I am missiing something very basic (am I?) . All I want to do is matching any sequence of characters upto a speical sequence for example XYZ, then continue. I used this pattern:"(?<found>.*)XYZ" . Now if the string is "blah blah XYZ mendhak :P XYZ" I want the group 'found' to have two values, but this pattern ignores the first XYZ and just matches the second. I tried lookahead and behind assertions with no luck. It should be very simple, but I cant do it . Please help.
    Last edited by Lunatic3; Jan 25th, 2004 at 05:38 PM.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi Lunatic.

    I think it's because the * is "greedy" it will continue to the last occurence. if you use *? instead it should halt at the first occurence.

    I'm not to experienced with RegEx but I have seen this explained somewhere at http://www.regular-expressions.info/charclass.html


    Hope it helps.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Hi pax

    Thank you very much. I think I tried those 'lazy' quantifiers with no luck. Maybe I have not used them in a correct syntax because the original pattern was not simple as one I mentioned here.

    And that tutorial about Regular Expressions is very good. Thanks again.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width