Erlang Programming/Using regexp

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Regular Expressions[edit | edit source]

2> re:run("hello world","w.+d").
{match,[{6,5}]}

The regular expression, "w.+d" matches the string, "hello world" at location 6 for 5 chars.

9> re:replace("10203040","([2-4]0)+","01",[{return,list}]).
"1001"

Makes a substitution, replacing "203040" with "01".