regex - Java Regular Expression repeated group capture -


i getting problem capturing repeated group here, can help?

string : ushinski k. d. (konstantin dmitrievich)

the regex i'm using :

(?i)(.*)((?:[a-z]{1,2}\.\s)+)\(.* 

but capturing "ushinski k. " group 1 , "d. " group 2. target capture "ushinski " group 1 , "k. d. " group 2. highly appreciated.

regex demo

you have use (.*?) or can use word boundaries (\b.*\b) instead of (.*) take @ post what difference between regex (.*?) , (.*)?

(?i)(.*?)\s((?:[a-z]{1,2}\.\s)+)\(.* 

or

(?i)(\b.*\b)\s((?:[a-z]{1,2}\.\s)+)\(.* 

regex demo 1

regex demo 2


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -