Java regex pattern between two characters having a repeating appearance

I have a text file containing a string

<><> name: idontknow <><><> dob: <> 

I want to get only the string name and dob, but with the regex, I get <> name and <> <> dob.
The regex sample I used is

 (?<=>).*?(?=:) 

Any suggestion would be a big help.

+4
source share
1 answer

You want to match characters other than < or > . You can use a negative character class instead of using . that matches something:

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

See how it works on the Internet: rubular

+5
source

All Articles