Using some regular expressions in text-pad produces an endless-loop.
For example:
try to convert a sequence of blanks into nothing
In the upper input area you type: :blank:*
In the lower input area you type nothing
Has anybody else encountered this problem or is there something wrong in my understanding of reg expressions.
But I think Textpad should in ow way run into an endless loop with the consequnce that I have to kill the process.
Peter Rohleder
using some reg expressions produces endless-loop
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
Andreas
Re: using some reg expressions produces endless-loop
Let's imagine a line that starts with a few blanks, then comes something else (whatever, it doesn't matter).
First step when this regex substitution is done:
match all the blanks at the start of the line, replace them by nothing.
Now all that is left is whatever came after these blanks.
Now trying to match again:
:blank:* matches 0 blanks or 1 blank or 2 blanks or ...
ok, best match Textpad can make is 0 blanks at the beginning of the line.
These 0 blanks (or better: nothing) will be replaced by nothing.
Now Textpad starts to match immediately after the replacement, i.e. at the beginning of the line.
ok, best match Textpad can make is 0 blanks at the beginning of the line.
These 0 blanks (or better: nothing) will be replaced by nothing.
Now Textpad starts to match immediately after the replacement, i.e. at the beginning of the line.
ok, best match Textpad can make is 0 blanks at the beginning of the line.
These 0 blanks (or better: nothing) will be replaced by nothing.
Now Textpad starts to match immediately after the replacement, i.e. at the beginning of the line.
Do you see now what is happening?
If you use a + instead of the *, no empty strings will match, so no endless loops.
First step when this regex substitution is done:
match all the blanks at the start of the line, replace them by nothing.
Now all that is left is whatever came after these blanks.
Now trying to match again:
:blank:* matches 0 blanks or 1 blank or 2 blanks or ...
ok, best match Textpad can make is 0 blanks at the beginning of the line.
These 0 blanks (or better: nothing) will be replaced by nothing.
Now Textpad starts to match immediately after the replacement, i.e. at the beginning of the line.
ok, best match Textpad can make is 0 blanks at the beginning of the line.
These 0 blanks (or better: nothing) will be replaced by nothing.
Now Textpad starts to match immediately after the replacement, i.e. at the beginning of the line.
ok, best match Textpad can make is 0 blanks at the beginning of the line.
These 0 blanks (or better: nothing) will be replaced by nothing.
Now Textpad starts to match immediately after the replacement, i.e. at the beginning of the line.
Do you see now what is happening?
If you use a + instead of the *, no empty strings will match, so no endless loops.