P Peter Thornqvist Nov 5, 2006 #1 How would I design a regular expression to find the first occurence of a specific pattern and not look for more matches?
How would I design a regular expression to find the first occurence of a specific pattern and not look for more matches?
P Peter Thornqvist Nov 5, 2006 #2 Just to clarify, I can't use the {n} quantifier since this doesn't prevent Regex from parsing the entire string even if a match has been found. Is there any other way to accomplish what I want, i.e just find the first occurence and then stop?
Just to clarify, I can't use the {n} quantifier since this doesn't prevent Regex from parsing the entire string even if a match has been found. Is there any other way to accomplish what I want, i.e just find the first occurence and then stop?
M Martin Honnen Nov 5, 2006 #3 Peter said: How would I design a regular expression to find the first occurence of a specific pattern and not look for more matches? Click to expand... If you use the Match method <http://msdn.microsoft.com/library/d...xtRegularExpressionsRegexClassMatchTopic1.asp> then it returns only the first match and you can check the Success property of that match. You would need to explictly call the NextMatch method to look for more matches.
Peter said: How would I design a regular expression to find the first occurence of a specific pattern and not look for more matches? Click to expand... If you use the Match method <http://msdn.microsoft.com/library/d...xtRegularExpressionsRegexClassMatchTopic1.asp> then it returns only the first match and you can check the Success property of that match. You would need to explictly call the NextMatch method to look for more matches.
P Peter Thornqvist Nov 5, 2006 #4 If you use the Match method <http://msdn.microsoft.com/library/d...xtRegularExpressionsRegexClassMatchTopic1.asp> then it returns only the first match and you can check the Success property of that match. You would need to explictly call the NextMatch method to look for more matches. Click to expand... Thank you! That was exactly what I was looking for.
If you use the Match method <http://msdn.microsoft.com/library/d...xtRegularExpressionsRegexClassMatchTopic1.asp> then it returns only the first match and you can check the Success property of that match. You would need to explictly call the NextMatch method to look for more matches. Click to expand... Thank you! That was exactly what I was looking for.