Closed jtomaszewski closed 4 years ago
Hi Jack, as the docs state, you have to have a matching group in your regex, which you don't. Try /(\n)/g
instead of /\n/g
and nothing will get swallowed. Your expect
won't succeed because (at least in my test) it returned <br />
instead of <br>
, but that is obviously a minor detail.
Also, no need to include {match}
in the replacement function, your second example works fine (it would just re-add the \n
's after the <br />
's).
You're right! Thanks.
Somehow I didn't notice it in the docs. (Or did I read them at all? Don't remember it now. Always read the docs first.)
Currently, following code:
throws an error on the
expect
line:Which means, the
\n\n
gets replaced into only one<br />
instead of two; Also, the last\n
in the didn't get replaced at all.Also, why do I have to do this:
?
I'd expect from the documentation that
would be enough, but then some text between the newlines get "swallowed" (it doesn't appear in the final string).