regex - Java - Pattern matching between the same pattern -
my sample string:
ghgduysgd fdferfdf bvfxbgdf gdfgdfg
i need find contents between a's.
i have (?<=a).*
matches contents after a. want find between a.
first iteration: ghgduysgd
second iteration: fdferfdf
i want data above manipulation. can regex?
you alrady use lookbehind in regex, change use lookahead:
(?<=a).*(?=a|$)
then make .*
non-greedy stop @ first available "ending" a
:
(?<=a).*?(?=a|$)
edit: a|$
tobias_k's comment below, a
Comments
Post a Comment