I am writing a simple syntax shortcut in JavaScript, and I need to find a way to test with multiple regular expressions at the same time.
The idea is to figure out what comes first, so I can define a new set of expressions to search for.
Expressions can be something like this:
/<%@/, /<%--/, /<!--/And/<[a-z:-]/
First I tried a strategy in which I combined expressions in groups such as:
/(<%@)|(<%--)|(<!--)|(<[a-z:-])/
Thus, I was able to find out which group was not undefined. But the problem is that some subexpressions contain groups or backrefferences.
So my question is this:
Does anyone know a good and reasonable way of finding matches with multiple regular expressions in a string?