473,385 Members | 2,005 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,385 software developers and data experts.

regex multiline modifier and windows line endings


In regex, ^ and $ shoudl match start/end of a line when the 'm' /multiline
modifier is set -- however I just spent the better part of the day trying
to figure out why it wasn't working as expected. I used the query
test$
....and the text
test
test
test

Only the last instance of test would match -- that is expected without the
multiline flag. ( http://tinyurl.com/dx86w ) however they should each
match with the multiline flag so long as there's no additional whitespace
after the fact ( http://tinyurl.com/7bap6 ).

Finally, out of ideas, I replaced \r\n with \n on all of my _POST data --
and presto, it worked. So, my question is -- why won't it work on data
with windows line endings? Is there a built in function for changing the
line ending style or something? It seems there should be a more elegant
solution than running a find/replace on all of my user-input just to make
sure the line ending style are liked by PCRE.

Thanks

A.
Jan 31 '06 #1
2 4376
On Tue, 31 Jan 2006 15:41:47 -0500, Allen wrote:

In regex, ^ and $ shoudl match start/end of a line when the 'm' /multiline
modifier is set -- however I just spent the better part of the day trying
to figure out why it wasn't working as expected. I used the query
test$
...and the text
test
test
test

Only the last instance of test would match -- that is expected without the
multiline flag. ( http://tinyurl.com/dx86w ) however they should each
match with the multiline flag so long as there's no additional whitespace
after the fact ( http://tinyurl.com/7bap6 ).

Finally, out of ideas, I replaced \r\n with \n on all of my _POST data --
and presto, it worked. So, my question is -- why won't it work on data
with windows line endings? Is there a built in function for changing the
line ending style or something? It seems there should be a more elegant
solution than running a find/replace on all of my user-input just to make
sure the line ending style are liked by PCRE.

Thanks

A.

Allen, I've never encountered such problem because I normally
clean up all "\r" characters, whenever I encounter them,
but there is a parameter "auto_detect_line_endings" in your php.ini
which is normally set to "Off".

--
http://www.mgogala.com

Feb 3 '06 #2
On Fri, 03 Feb 2006 07:40:04 -0500, Mladen Gogala <go****@sbcglobal.net>
wrote:
On Tue, 31 Jan 2006 15:41:47 -0500, Allen wrote:
Allen, I've never encountered such problem because I normally
clean up all "\r" characters, whenever I encounter them,
but there is a parameter "auto_detect_line_endings" in your php.ini
which is normally set to "Off".


That'll probably do it. In my code, I never use \r -- the problem was
from user-input, which hadn't occurred to me to manually clean up. Thanks
much.
Feb 6 '06 #3

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: Mr.Clean | last post by:
I am working on modifying a syntax highlighter written in javascript and it uses several regexes. I need to add a language to the avail highlighters and need the following regexes modified to...
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: JackRazz | last post by:
Anyone know the regular expression to match a blank line where the byte sequence is "0D 0A 0D 0A" ive tried "\r\n\r\n+", "^$+" "\n\r" with no success. Any Ideas? Thanks - JackRazz This is...
5
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated...
4
by: Fuzzyman | last post by:
Hello all, I'm handling some text files where I don't (necessarily) know the encoding beforehand. Because I use regular expressions to parse the text I *must* decode UTF16 encoded text...
3
by: ommail | last post by:
Hi! I have a simple regural expression: \w+$ and text to match: abc dddd ggg hhh
2
by: felciano | last post by:
Hi -- Is there a standard way to use the csv module to export data that contains multi-line values to Excel? I can get it mostly working, but Excel seems to have difficulty displaying the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.