>>>>> "Berend" == Berend de Boer <berend@...> writes:
Berend> What happens is that the start position is 1, and the end
Berend> position is 0. has_matched is always true. I'm not sure
Berend> how to solve this. This was what I have now:
My previous solution didn't work that well. Here another attempt:
new_end, previous_end: INTEGER
do
old_subject_start := subject_start
from until not has_matched loop
STRING_.append_substring_to_string (a_string, subject, subject_start,
captured_start_position (0) - 1)
append_replacement_to_string (a_string, a_replacement)
previous_end := captured_end_position (0)
match_substring (subject, previous_end + 1, subject_end)
new_end := captured_end_position (0)
if previous_end = new_end then
-- Get out of loop, we're matching the same thing,
-- i.e. we're not making any progress.
match_count := 0
end
end
So if the captured_end_position doesn't move, we quite the loop.
--
All the best,
Berend de Boer