Monday, 15 March 2010

c# - regex not giving all the possible matches -


I have to get all the possible matches for the word in the regular expression given in C # and C #. But the Regex.Matches () function is not giving it up. For example

  Regex.Matches ("datamatics", "[^ aeiou] a [^ aeou]")   

returns only two matches

  dat mat   

This is not giving "Tam" as a match. Can someone explain to me why he is not giving "Tam" as a match and how can I get these three?

You can not get overlapping matches in Reggae You have several ways of working around it, though . You can either use Regex.Match , and specify a preliminary index (use a loop to go through your entire string), or you can see, Or look like this:

  (? = [^ Aeou] a) [^ aeou]   

This works because see and look-eyed characters Do not consume it, it gives a mail in which the match is indexed, because you have to use it instead of capture, because Only one letter has been captured.

No comments:

Post a Comment