This is happening because of backtracking of greedy quantifiers in regex.
To avoid backtracking I know two choices : atomic group or possessive quantifiers. Both mean match as many symbols as possible with greedy quantifier and never release(backtrack) symbols.
So I just used atomic group for first greedy plus and problem has gone.
So, regex becomes:
(?>\\w+) means, that it matches as many one of [a-zA-Z0-9_] as possible and never release matched symbol.
This article will be useful to read.