This is a discussion on RE: [PHP] ereg problem? within the PHP General forums, part of the PHP Programming Forums category; > -----Original Message----- > From: sven [mailto:svenie@gmx.li] > Sent: 25 July 2003 10:35 > > by ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
> -----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 |