Re: Regular Expressions: find_replace_limit doesn't make all replacements

new topic     » goto parent     » topic index » view thread      » older message » newer message

Some new demo code comparing equivalent correct behaviour of find_replace_callback() . Comparative bad then good output is;

~0.013AUD~0.00%~0.000AUD~Sell~42~1  4.379MAUD~- -0.00AUD~-  Energy~Minerals     
~0.013AUD~0.00%~0.000AUD~Sell~42~1~4.379MAUD~-~-0.00AUD~-~Energy~Minerals       

So would seem conclusive that there is a bug in Euphoria's backend implementation of find_replace_limit() . Anyone want to quickly point me to where this is on github and i'll take a quick look.

include std/regex.e 
function my_convert(sequence params) 
	return "~" & params[2]	--replace matched whitespace (\s)  with '~' and append the first capture of non-whitespace (\S) 
end function 
 
regex pattern = regex:new( `\s+(\S+)` ) 
 
sequence string = "\t0.013AUD\t0.00%\t0.000AUD\tSell\t42\t1\t4.379MAUD\t-\t-0.00AUD\t-\tEnergy Minerals" 
 
puts(1, regex:find_replace_limit( pattern, string, "~\\1", 20 ) & '\n') 
puts(1, find_replace_callback(regex:new( `\s+(\S+)` ), string,routine_id("my_convert")) ) 
abort(2) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu