forum-msg-id-136748-edit

Original date:2022-02-26 19:23:54 Edited by: ghaberek Subject: Re: Regular Expressions: find_replace_limit doesn't make all replacements

Is this what you're looking for? It works fine for me. I also tested here: https://regex101.com/r/wWCCCJ/1

include std/regex.e 
regex pattern = regex:new( `\s+(\s+)` ) 
 
sequence string = "        0.013AUD        0.00%   0.000AUD        Sell    42      1       4.379MAUD      -       -0.00AUD        -       Energy Minerals\n" 
sequence result = regex:find_replace_limit( pattern, string, `~\1`, 20 ) 
 
? equal( result, "~ 0.013AUD~ 0.00%~ 0.000AUD~ Sell~ 42~ 1~ 4.379MAUD~ -~ -0.00AUD~ -~ Energy Minerals\n" ) 

PS: Use the "raw" backtick strings when writing regular expressions to avoid escaping backslashes and help prevent errors.
PPS: Use the {{{ and }}} blocks when you want to format raw plain text in forum posts. I've edited them in for you above.

-Greg

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu