Reputation: 1690
I've tried [\n$] and a few other things, but none seem to work in Erlang (even if they work on regexr). What's the right way to do this in Erlang (re:compile)?
Upvotes: 1
Views: 290
Reputation: 41548
Use (\n|$)
:
> re:run("foobar", "(\n|$)").
{match,[{6,0},{6,0}]}
> re:run("foo\nbar", "(\n|$)").
{match,[{3,1},{3,1}]}
That is, there are two alternatives: either match a newline, or the end of the string.
Upvotes: 2