Re: match_replace for every instance forever

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...
euphoric said...

I want to turn all multiple space sequences in a string to a single space.

I'd do it with a slightly modified version of the std routine match_replace:

Let me caveat that this will work for the scenario you're looking for, where the replacement is smaller than the needle. It will not work if you want to replace, say, "12" with "012".

You could also use regexes:

-- ck.ex 
include std/regex.e 
include std/console.e 
regex r = regex:new( " +" ) 
display( regex:find_replace( r, "a  b    c d   e   f  g    h"," ") ) 

$ eui ck.ex 
a b c d e f g h 

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu