Re: Not terminating loop possible with RX_PCRE_REGULAR_EXPRESSION.replace_all

Eric Bezault <ericb-D6Qt/9opevxWk0Htik3J/[email protected]> Tue, 16 Jun 2009 23:21:28 +0200
Newsgroups gmane.comp.lang.eiffel.gobo.general
Message-ID <[email protected]>
Berend de Boer wrote:
>>>>>> "Berend" == Berend de Boer <[email protected]> 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.

I now fixed it in the SVN repository in such a way that it works
as well when there is no ^ at the beginning of the regexp. In that
case it is assumed that there is only one matching empty string
between each character. Can you please give it a try and let me
know if it works for you?

-- 
Eric Bezault
mailto:ericb-D6Qt/9opevxWk0Htik3J/[email protected]
http://www.gobosoft.com


------------------------------------

To Post a message, send it to:   [email protected]
To Unsubscribe, send a blank message to: [email protected]! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/gobo-eiffel/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/gobo-eiffel/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/