I am processing text using Java Regexes (1.6) which contain quantifiers and I wish to return the number and values of matched groups. A simple example is:
I made, what I believed to be, an error in a regular expression in Java recently but when I test my code I don't get the error I expect.
The expression I ...
I don't know how to explain the problem in plain English, so I help myself with regexp example. I have something similar to this (the example is pretty much simplified):
Hello how does java and regex group work. For ex. I want to match any text 'something', the way I'd match this is .+\s+'(.+)'{1}, how can I replace any text 'something' ...
No, it was my fault.. I posted wrong. By matching (.*document.*), I was capturing the whole expression. If the input was "calendar simple", the lookahead (.*simple.*) would have nothing left to match. The correct pattern would be (calendar)(?!.*simple.*). This would return true for "calendar" or 'calendar some words", but false for "calendar simple". I tested this with the RegexTestHarness in the ...
The test page says that matches() returns false. Look at the difference between the matches() and find() methods. My guess is that if the test page reported what find() returned, it would have been true. That's what I would expect for the regex and input you have shown. However I'm not sure why the final " is included - did your ...
Please help me understand how to use Java regular expressions: I have an expression similar to this: "([^X]+)(X[^X]*)+"This should match stuff like "asaasaXdfdfdfXXsdsfd". How does one access all the matches for the second group (the second groups has a Kleene operator added so it is not really just one group --- but match.groupCount() is always 2) Here is roughly the code: ...