Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Jim Lucas
Sam Stelfox wrote: > The following snippet is untested and using Ash's regex (it is accurate > \s matches any white space). $content is what is getting stripped of the > new lines and $filtered is the cleansed output. See if that does the > trick for you. > > $lines = str_split(PHP_EOL, $content);

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ashley Sheridan
On Fri, 2009-09-04 at 16:13 +0200, Ralph Deffke wrote: > and this is the PHP_EOL solution: > $dtd = preg_replace( "/[". PHP_EOL . "]+/", "". PHP_EOL . "", $dtd); > > dont ask me why two empty strings are needed to surround the PHP_EOL but its > does it. > > Why this works? we have got an INTERPRE

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ralph Deffke
and this is the PHP_EOL solution: $dtd = preg_replace( "/[". PHP_EOL . "]+/", "". PHP_EOL . "", $dtd); dont ask me why two empty strings are needed to surround the PHP_EOL but its does it. Why this works? we have got an INTERPRETER here any \n is transtlated into 0x0D an \r into 0x0A so the patte

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Sam Stelfox
The following snippet is untested and using Ash's regex (it is accurate \s matches any white space). $content is what is getting stripped of the new lines and $filtered is the cleansed output. See if that does the trick for you. $lines = str_split(PHP_EOL, $content); $filtered = ''; foreach ($

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ralph Deffke
this works $dtd = preg_replace( "/\n+/", "\n", $dtd); "Martin Scotta" wrote in message news:6445d94e0909040653i44716f79m972f11055599...@mail.gmail.com... > On Fri, Sep 4, 2009 at 10:37 AM, Ralph Deffke wrote: > > > the problem is some have got \t\n > > some are just \n\n\n > > > > using PHP_

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Martin Scotta
On Fri, Sep 4, 2009 at 10:37 AM, Ralph Deffke wrote: > the problem is some have got \t\n > some are just \n\n\n > > using PHP_EOL is a must > > I thing must be something with the /../sm attributes to the regex, spend > like half an hour, but didn't get it, I'm running against a dead line, > d

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ashley Sheridan
On Fri, 2009-09-04 at 15:45 +0200, Ralph Deffke wrote: > I'm working on DTD's > > "Ashley Sheridan" wrote in message > news:1252071932.24700.153.ca...@localhost... > > On Fri, 2009-09-04 at 15:37 +0200, Ralph Deffke wrote: > > > the problem is some have got \t\n > > > some are just \n\n\n > >

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ralph Deffke
I'm working on DTD's "Ashley Sheridan" wrote in message news:1252071932.24700.153.ca...@localhost... > On Fri, 2009-09-04 at 15:37 +0200, Ralph Deffke wrote: > > the problem is some have got \t\n > > some are just \n\n\n > > > > using PHP_EOL is a must > > > > I thing must be something with t

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ashley Sheridan
On Fri, 2009-09-04 at 15:37 +0200, Ralph Deffke wrote: > the problem is some have got \t\n > some are just \n\n\n > > using PHP_EOL is a must > > I thing must be something with the /../sm attributes to the regex, spend > like half an hour, but didn't get it, I'm running against a dead line, >

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ralph Deffke
the problem is some have got \t\n some are just \n\n\n using PHP_EOL is a must I thing must be something with the /../sm attributes to the regex, spend like half an hour, but didn't get it, I'm running against a dead line, doesn't seem to be that easy if regex is not the everydays need u have

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ashley Sheridan
On Fri, 2009-09-04 at 15:28 +0200, Ralph Deffke wrote: > ok > preg_replace( "/^\s*$/m", "", $somestring) > does not take empty lines out > > "Ashley Sheridan" wrote in message > news:1252069539.24700.150.ca...@localhost... > > On Fri, 2009-09-04 at 14:58 +0200, Ralph Deffke wrote: > > > Hi all,

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ralph Deffke
ok preg_replace( "/^\s*$/m", "", $somestring) does not take empty lines out "Ashley Sheridan" wrote in message news:1252069539.24700.150.ca...@localhost... > On Fri, 2009-09-04 at 14:58 +0200, Ralph Deffke wrote: > > Hi all, I'm a bit under stress, maybe somebody knows the regex on a snap. > > u

Re: [PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ashley Sheridan
On Fri, 2009-09-04 at 14:58 +0200, Ralph Deffke wrote: > Hi all, I'm a bit under stress, maybe somebody knows the regex on a snap. > using PHP_EOL would be great. > > thanks > ralph_def...@yahoo.de > > > The regex that would match a line containing only whitespace would look like this: ^\s*$

[PHP] how to strip empty lines out of a txt using preg_replace()

2009-09-04 Thread Ralph Deffke
Hi all, I'm a bit under stress, maybe somebody knows the regex on a snap. using PHP_EOL would be great. thanks ralph_def...@yahoo.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php