Java regex pattern between two character having repetitive appearance

java, regex, string

Solution

You want to match characters apart from `<` or `>`. You can use a negated character class instead of using `.` which matches anything:

[^<>]*?(?=:)

See it working online: rubular

Problem

I have a text file containing string ``` <><> name: idontknow <><><> dob: <> ``` I want to get only the strings name and dob but with the regex i am getting <> name and <><> dob. The regex pattern which i used is ``` (?<=>).*?(?=:) ``` Any suggestion would be a great help.

Original source