M. Pope M. Pope - 1 month ago 6x
Javascript Question

Javascript Regular Expressions - using * with multiple characters

I'm parsing a string that looks like this:

int num 1, num2, num3;

//do some other stuff

In betwee those lines, there is a \r\n. I'm looking to replace \r\n with simply \n, and I got that working fine, howerver, I'd like for it to look for multiple copies of /r/n in a row. In other words:

/r/n <-- is found

/r/n/r/n <-- this is found also

/r/r/n/n/n <-- this is not found

Here is my current statement:

MyData.replace (/(/r|/n)*/g, "someStuff");

Do you know any way of how to make the * character apply to multiple characters, so I could look for repetitions of "/r/n"* rather than (/r|/n)* which finds either /r or /n any number of times.




The plus matches one or more times.

Or this:


The g matches all occurrences of the string

Depends on your need or actual code, if you can post it.