Re: match_replace for every instance forever
- Posted by mattlewis (admin) Nov 08, 2011
- 1292 views
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