Friday, November 1, 2013

Case Insensitive Regex in Erlang

Case insensitive matches with regular expression can be done by specifying caseless as one of the options.
1> S = "Hi there, hello there. Hello world!".
"Hi there, hello there. Hello world!"

2> re:run(S, "hello", [global, caseless]).
{match,[[{10,5}],[{23,5}]]}

3> re:run(S, "hello", [global]).
{match,[[{10,5}]]}

4> re:run(S, "hello", []).
{match,[{10,5}]}