473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Regex multiline option does't work - why?

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

May 19 '07 #1
3 2003
* om****@wp.pl 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
May 19 '07 #2
* om****@wp.pl 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/Visual...dbackID=277746

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

Regards

May 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ali Eghtebas | last post by:
Hi, I've made this regex to catch the start of a valid multiline comment such as "/*" in e.g. T-SQL code. "(?<=^(?:*'*')*?*)(?<!^(?:*'*')*?--.*)/\*.*?$" With Multiline option on. As we know...
2
by: Mortimer Schnurd | last post by:
Hi All, I am a VB 6 programmer who is now trying to learn C#. In doing so, I am trying to convert some of my VB modules to C#. I routinely user Reg Expressions in VB and am having some trouble...
6
by: BigAl | last post by:
Perhaps someone here can help me out... RegEx: "^.*\d{5}(-\d{4})?.*$" Intended Purpose: To strip out the City/State/ZipCode line from a signature. Sample Text: Joe Jackson 131 W. 5th...
5
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated...
7
by: MrNobody | last post by:
I'm trying to do some regex in C# but for some reason linebreaks are causing my regex to not work. the test string goes like this: string ss = "<tagname...
3
by: Efi | last post by:
Hello, I am trying to capture empty lines, for example : 1. ABCDEF 2. 3. abcdef I would like to capture line number 2. I am using the following regex - new...
10
by: igor.kulkin | last post by:
I have a small utility program written in Python which works pretty slow so I've decided to implement it in C. I did some benchmarking of Python's code performance. One of the parts of the program...
7
by: Nightcrawler | last post by:
Hi all, I am trying to use regular expressions to parse out mp3 titles into three different groups (artist, title and remix). I currently have three ways to name a mp3 file: Artist - Title ...
2
by: GS | last post by:
How can one avoid capturing leading empty or blank lines? the data I deal with look like this "will be paid on the dates you specified. xyz supplier amount: $100.52 when: September 07,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.