Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #11993
| Message-ID | <3047167.u27dj7xdmW@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-11-26 19:46 +0100 |
| Subject | Re: finding newlines |
| Newsgroups | comp.lang.php |
| References | <l6vst0$ijk$1@speranza.aioe.org> <l70ats$mhk$1@dont-email.me> <l72nu1$ghd$1@dont-email.me> |
Denis McMahon wrote:
> On Mon, 25 Nov 2013 20:11:40 +0000, Denis McMahon wrote:
>> $lines=explode("\n",preg_replace("/[\r\n]+/","\n",$progressNote));
>
> or of course:
>
> $lines=preg_split("/[\r\n]+/",$progressNote);
Now that I told you. However, “of course” *that* is questionable: within
double-quotes, “\r” and “\n” are expanded as *string* escape sequences,
before preg_split() sees them. When in doubt, use either single-quotes or
double-quotes with double-backslash.
I prefer to use double-backslash also with single-quotes in case someone
decides in the future to support more escape sequences. The resulting code
style also is more consistent because with trailing backslash you *must* use
double-backslash unless you want to escape the string delimiter: '\' is
likely to become a syntax error (unterminated string literal); '\\' is not.
PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
finding newlines bill <william@TechServSys.com> - 2013-11-25 11:12 -0500
Re: finding newlines Christoph Michael Becker <cmbecker69@arcor.de> - 2013-11-25 17:32 +0100
Re: finding newlines bill <william@TechServSys.com> - 2013-11-26 09:36 -0500
Re: finding newlines Richard Yates <richard@yatesguitar.com> - 2013-11-25 08:34 -0800
Re: finding newlines Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-25 20:11 +0000
Re: finding newlines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-25 22:23 +0100
Re: finding newlines Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-26 18:05 +0000
Re: finding newlines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-26 19:46 +0100
Re: finding newlines Wizard-Of-Oz <somewhere@over.rainbow.com> - 2013-11-30 16:50 +0000
Re: finding newlines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-01 17:11 +0100
Re: finding newlines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-25 22:18 +0100
Re: finding newlines Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-25 16:36 -0500
Re: finding newlines bill <william@TechServSys.com> - 2013-11-27 05:11 -0500
Re: finding newlines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-27 16:56 +0100
Re: finding newlines bill <william@TechServSys.com> - 2013-11-28 11:42 -0500
Re: finding newlines Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-28 20:20 +0100
Re: finding newlines Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-29 00:57 +0000
Re: finding newlines Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-27 11:47 -0500
Re: finding newlines bill <william@TechServSys.com> - 2013-11-28 11:09 -0500
csiph-web