PDA

View Full Version : RegEx Help Needed...



JBottero
10-21-2007, 01:13 AM
I need to replace linefeeds and returns between test from a text box input. There might be any number in any order. For example"


test\r\r\r\n\r\n\rtest

Should change to:


test<SomeString>test

I've tried:


$data = preg_replace("/[\r|\n]*/", '<SomeString>', $original_data);

But it doesn't work as I need...

So, any Reg Ex gurus out there have any suggestions?

Twey
10-21-2007, 01:30 AM
$data = preg_replace('/(?:\r?\n)+/', '<SomeString>', $original_data);Note the existence of nl2br() if you're attempting to convert them to line breaks, however.
http://nojailforpot.comHear hear!

JBottero
10-21-2007, 02:19 AM
$data = preg_replace('/(?:\r?\n)+/', '<SomeString>', $original_data);Note the existence of nl2br() if you're attempting to convert them to line breaks, however.
Thanks!

Actually I'm trying to parse text-box input into an XML file when I can not rely on consistency in how many or what kind of "white space" ends up between paragraphs.