質問

Earlier I posted a question about regex which resulted in stackoverflow error in java. My Regex was greedy and many commented to use possessive quantifier in regex. So, I started learning Possessive quantifier in regex.

I tried to match string between double quotes. My regex is

"([^\\"]|\\.)++"

I tried to match the string

"Hello I am \" chitti"

While matching there was backtracks. I tested using http://regex101.com/#PCRE. The link to regex is REGEX 101 LINK

enter image description here

Can someone please explain why there is a backtrack involved steps 6,8,10 etc

役に立ちましたか?

解決

There shouldn't be a backtrack there. I would expect (and RegexBuddy shows) backtracks at the \" and at the final ", but not in these positions.

RegexBuddy screenshot

Perhaps regex101.com displays a BACKTRACK message also when the regex engine explicitly discards a potential backtracking position, but that's only speculation on my part.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top