| | Refresh | Back to list | Edit | Add note | | | New bug | New request | New idea | |
TedNPad : Bug (0 votes)

#62: Regexp zero-length replace loop

Category: Search SubCategory: RegExps
Status: Fixed (2021-03-08 01:51:34) Priority: Next Release Difficulty: Difficult Created: jsimlo
Version: 6.0.2.beta
Comment from jsimlo on Wed, Apr 3, 2013, 18:11 (comment id #125)
If the last match was zero-length and the current match is also zero-length at the same position, an infinite loop begins. To break such loop, the following match after a zero-length match at the same position is prohibited to have a length of zero. This prohibition interacts with backtracking, and so the second best match is chosen instead. For example, suppose we search and replace in the text "bar". Search pattern "\w??" searches lazyli for one or none word character. Replace pattern "<\&>" puts each matching occurence between braces "<" and ">". The exspected result is "<><b><><a><><r><>", the actual result is "<>b<>a<>r<>". The engine, to prevent an infinite loop, prohibits any match at the same position as the last zero-length match. It should fallback to the second best match instead of giving up the starting position.

Public readonly listing for anonymous users.
Bugy ver. 0.0.1, a minimalist bugtracker and ideabox.
(c) 2013, Juraj Simlovic, Medvedik. All rights reserved.
Developed with TED Notepad, free notepad replacement.