J
jehugaleahsa
Hello:
I have an input string that is supposed to follow a particular syntax.
I am making a simple parser. In doing so, I need to write a lexical
analyzer. I have decided to implement it in terms of regular
expressions.
I want to take a list of regular expressions and iterate over them,
finding the first one that matches. Of course, it has to match AND the
match must start at index == 0.
The problem I have is that the regex has to look through the whole
string. I want to limit it to being the first position. Would
appending ^ to every regex work? I am just looking for a way to short-
circuit.
Thanks,
Travis
I have an input string that is supposed to follow a particular syntax.
I am making a simple parser. In doing so, I need to write a lexical
analyzer. I have decided to implement it in terms of regular
expressions.
I want to take a list of regular expressions and iterate over them,
finding the first one that matches. Of course, it has to match AND the
match must start at index == 0.
The problem I have is that the regex has to look through the whole
string. I want to limit it to being the first position. Would
appending ^ to every regex work? I am just looking for a way to short-
circuit.
Thanks,
Travis