Discussion » Regex Question...

This is a read-only copy. The forum ran on iamcal.com from 2000 until its database was lost in 2016, and this topic was rebuilt from copies saved by the Internet Archive's Wayback Machine. Some replies may be missing.
Posted by Govan, 11:04, 20th June 2003:
 
I know it's hideously basic stuff but I just want to make sure I've got it right..

ereg_replace("\015(\012)?", "\012", $row);

will replace 015 or 015012 with 012, yes?

help me o perl and php persons....

ps: my copy of 'Mastering regular expressions' is still in the post otherwise I wouldn't be asking thick questions.
Posted by beargod, 11:14, 20th June 2003:
 
Is this for PHP? If it is (I have no idea for Perl/cgi) uk.php.net/ereg is your guide :)
Posted by Govan, 11:20, 20th June 2003:
 
Unfortunately the php documentation sucks ass when it comes to breaking you in to regex. boo-hiss!
Posted by beargod, 11:21, 20th June 2003:
 
oh ok then that sucks, Cals not even on, what use is he?
Posted by Govan, 11:24, 20th June 2003:
 
help us obi wan, you're our only hope.......
Posted by beargod, 11:59, 20th June 2003:
 
If the (,),\,? in "\015(\012)?" do what i think they do then yes this would work
Posted by cal, 12:47, 20th June 2003:
 
i'm pretty sure that \012 doesn't do what you think it does here. i'd use:

$row = preg_replace("/\r\n?/", "\n", $row);
Posted by Govan, 13:53, 20th June 2003:
 
Thanks cal & BG, it seems to be working ok with the octals (so far)

from the manual

double quoted strings recognize....

\[0-7]{1,3} the sequence of characters matching the regular expression is a character in octal notation

...but then again, I know hee-haw about regex.
Posted by beargod, 14:04, 20th June 2003:
 
Don't thank me I am useless
Posted by Foghorn Leghorn, 14:09, 20th June 2003:
 
Well thanks for being useless BG.
Posted by beargod, 14:12, 20th June 2003:
 
s'alright