go to previous page   go to home page   go to next page

Answer:

(Rats! ){2,}

The last group "Rats! " in the string must be followed by a space in the above.

If you want the final space to be optional, the expression could be (Rats! ){1,}(Rats!) ?

There is a space before the '?'. Another (probably better) way to write this is (Rats! )+(Rats!) ?


More Greed

Regular Expression
(Delimit with quotes)
String
(Delimit with quotes)

Quantifiers are greedy. This means that when a particular quantifier is busy matching characters from the string, it will "eat" as many characters as it can without preventing the remaining parts of the regular expression from matching.

For example, [A-D]{2,}[CDE]{2,5} matches "ABCD". The first part [A-D]{2,} matches "AB" but no further, allowing the second part [CDE]{2,5} to match "CD" .


QUESTION 21:

Is the string ACACDE matched by the above RE?