I am currently developping a regex to catch a number in a xml test.
<items><item id='123' something_cool='61461651'></item><items> I used '.*item id='\d'.*' and it works ! However is there a way to do it without '.*' at the begining and the end of the regex ?
.*are mandatory if you are usingmatchesmethod and your regex describes only fragment, since purpose ofmatchesis to check if entire string can be matched by regex. If you want to get only part of text which matches regex you need to useMatcher#find.