I’m just getting into regular expressions with Javascript… And I seem to have gone on and confused myself…
Some googling here and there didn’t do me any good either…
I know the Javascript syntax of:
var str = "Hello!";
var x = new RegExp(...);
document.write = x.eval(str);
Am I missing something here?
Edit: Apparently I wasn’t clear… I am new to Javascript Regular Expressions. From my understanding, regex and regexp are different. If so, what is the difference?
There are “RegExp class” syntax:
and “RegExp literal” syntax:
Each of these have their own advatages. The class syntax can handle variables, this way you can create dynamic regular expressions, the literal systax on the other hand is shorter, and you dont have to escape so much.
After you have your pattern, you can use a few regex methods, for example: