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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -