Question:
Using regular expressions in javascript, if I have a string that contains zero or more newlines or carriage returns, what is the best way to tell how many characters are after the last newline or carriage return?
Attempts:
I've tried various regular expressions, but with no luck. Say I have the string:
"_\nHELLO\nWORLD\nSALUTATIONS"
In normal output, it looks like this:
_
HELLO
WORLD
SALUTATIONS
Shouldn't /^(\r|\n){1}/g find a string globally g, with only one occurance {1} of a return or newline (\r|\n), or, in this case, "SALUTATIONS"? Instead no match is found.