[erlang-bugs] Module re, escape needs double backslash

Arif Ishaq <>
Tue Nov 20 09:17:46 CET 2012


Hi,

The backslash character as escape doesn't work as expected.

   Erlang R15B (erts-5.9) [smp:4:4] [async-threads:0]

   Eshell V5.9  (abort with ^G)
   1> String = "/* this is a C comment */".
   "/* this is a C comment */"
   2> re:run(String, "/\*.*?\*/").
   ** exception error: bad argument
        in function  re:run/2
           called as re:run("/* this is a C comment */","/*.*?*/")
   3> re:run(String, "/\\*.*?\\*/").
   {match,[{0,25}]}
   4>

Best regards


PS. The documentation in "erl5.9/lib/stdlib-1.18/doc/html/re.html" says:

".. the pattern

/\*.*?\*/

does the right thing with the C comments."

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20121120/ea86e1b6/attachment.html>


More information about the erlang-bugs mailing list