RE: [PHP] ereg problem?

From: Date: Fri, 25 Jul 2003 09:51:10 +0000
Subject: RE: [PHP] ereg problem?
Groups: php.general 
Request: Send a blank email to php-general+get-156816@lists.php.net to get a copy of this message
> -----Original Message----- > From: sven [mailto:svenie@gmx.li] > Sent: 25 July 2003 10:35 > > by the way, it's to complicated. the brackets [ and ] are used for > cha-groups. you can leave them for only one char. so this > would be the same: > "\\n" (you have to escape the backslash with a backslash) And then we get into the typical double-quoted-regexp-backslash-proliferation problem -- the above will pass \n as the regexp, which matches a newline *not* the intended literal \n. So now you have to escape the escaped escape, to get: "\\\\n" Which passes \\n as the regexp, which does indeed match a literal \n ! Another way to go is to use single quotes around the regexp, since a single-quoted string does not interpret \-expressions (except for \', of course!) -- so this is the same regexp as above: '\\n' I know which I prefer, but YMMV of course! Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#156816) next »