G
Guest
I'm using .NET 2.0.
I need (for performance reasons) to restrict Regex searches to a certain
portion of a large string. The Regex.Match functions allow me to input the
beginning and ending position of the search. However, what I need is to find
whether there is a Regex match that begins no later than a certain character
position.
For a trivial example, consider the string:
abcde
My regular expression is "cd", and my search range is characters 0-2. The
Regex.Match functions will fail on this search ("cd" is not in "abc"), but I
need it to find any matches that *begin* within the range, and "cd" does
begin on or before character 2.
I can't simply lengthen the allowed range (in this case searching 0-3
instead of 0-2), since my actual regular expressions match strings of
arbitrary length.
Any suggestions?
I need (for performance reasons) to restrict Regex searches to a certain
portion of a large string. The Regex.Match functions allow me to input the
beginning and ending position of the search. However, what I need is to find
whether there is a Regex match that begins no later than a certain character
position.
For a trivial example, consider the string:
abcde
My regular expression is "cd", and my search range is characters 0-2. The
Regex.Match functions will fail on this search ("cd" is not in "abc"), but I
need it to find any matches that *begin* within the range, and "cd" does
begin on or before character 2.
I can't simply lengthen the allowed range (in this case searching 0-3
instead of 0-2), since my actual regular expressions match strings of
arbitrary length.
Any suggestions?