[erlang-questions] Why is it necessary to "double-escape" [ characters in regular expressions?

Gaspar Chilingarov nm@REDACTED
Mon Mar 30 08:57:40 CEST 2009


Let's try on the simple example

2> "\q".
3> "\\q".

But do really "\\q" means 3 symbols or 2 ?

6> lists:map(fun(X) -> erlang:display(X) end, "\\q").

Well. So it's in your regular expression you put exactly 2 characters -
\ and [
which is required by a regexp to interpret [ as a character and not as 
class start symbol.

So it works quite predictable ;)


Gaspar Chilingarov

tel +37493 419763 (mobile - leave voice mail message)
icq 63174784
e mailto:nm@REDACTED mailto:gasparch@REDACTED
w http://gasparchilingarov.com/

More information about the erlang-questions mailing list