You are here: Re: help with regex « PHP Programming Language « IT news, forums, messages
Re: help with regex

Posted by John Dunlop on 08/04/06 14:06

Marcus:

> I am trying to include the literal '\' (backslash) character in a regex.

>From the beginning. What planet are you on? What country? Town?
System? PHP version? Regex flavour?

> I am not sure if I need to escape it, however...
>
> From http://www.regular-expressions.info/charclass.html:
> "To include a backslash as a character without any special meaning
> inside a character class, you have to escape it with another backslash.
> [\\x] matches a backslash or an x."
>
> From http://www.tin.org/bin/man.cgi?section=7&topic=regex:
> "...all other special characters, including `\', lose their special
> significance within a bracket expression."

The first is talking about regexes in general, the second about POSIX
regexes.

Take it from the horse's mouth: 'All non-alphanumeric characters other
than \, -, ^ (at the start) and the terminating ] are non-special in
character classes, but it does no harm if they are escaped.'.

http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

> These seem to contradict each other.

If they're talking about the same flavour of regex, yes.

--
Jock

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация