Regex multiline option does't work - why?

  • Thread starter Thread starter ommail
  • Start date Start date
O

ommail

Hi!

I have a simple regural expression:
\w+$

and text to match:
abc dddd
ggg
hhh

It should match three times:
dddd
ggg
hhh

but it only match once (for hhh).
Why? I USE multiline option so $ should match end of each line.
(I checked it in Python and Java and in these languages it worked
correctly).

Are there any other odd things in .NET Regex?

Regards
 
* (e-mail address removed) wrote, On 19-5-2007 13:39:
Hi!

I have a simple regural expression:
\w+$

and text to match:
abc dddd
ggg
hhh

It should match three times:
dddd
ggg
hhh

but it only match once (for hhh).
Why? I USE multiline option so $ should match end of each line.
(I checked it in Python and Java and in these languages it worked
correctly).

Are there any other odd things in .NET Regex?

Regards

This seems to be a bug in the framework. Which version of Windows are
you testing on? I just tested on Vista and I get the error. But I used
this construction in my courses before, so I know they worked at some point.

The funny thing is that if you use .+$, then it works, but the caputerd
text is one character too long. I haven 't yet looked in the debugger
which one that is, but I'm guessing either \r or \n.

Ok. couldn't resist, and just tested; the following expression works:

([\w\r]+?)$

So \r\n aren't seen as line end together, where they should be depending
on your systems settings.

It looks like the Regex engine bug day today. Early this morning a regex
that bluescreened my vista installation, and now this.

My guess is that it is a bug in either the 2.0 or the 2.5 framework. I
tested it in The Regulator (running under famework 1.1 under XP) and it
works like a charm. Testing under the Rad.RegexDesigner fails and that
is either running under 2.0 or 2.5 under both XP and Vista.

Jesse
 
* (e-mail address removed) wrote, On 19-5-2007 13:39:
Hi!

I have a simple regural expression:
\w+$

and text to match:
abc dddd
ggg
hhh

It should match three times:
dddd
ggg
hhh

but it only match once (for hhh).
Why? I USE multiline option so $ should match end of each line.
(I checked it in Python and Java and in these languages it worked
correctly).

Are there any other odd things in .NET Regex?

Regards

I submitted a bug to the Framework connect bug tracker. Please vote for
it and follow its progress here:

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=277746

Jesse Houwing
 
I tested it with Rad Software Rgular Expressions Designer (.NET 1.1)
and in regexlib.com, both on XP.

Regards
 
Back
Top