Paste: Replace occurences of string in string with string
Author: | paldepind |
Mode: | factor |
Date: | Thu, 3 Jan 2013 20:03:45 |
Plain Text |
: replace-string ( string match replace -- string' )
'[ [ _ ?head [ _ % ] [ [ first , ] [ rest ] bi ] if
dup empty? not ] loop ] "" make swap drop ;
"cheesecake" "cake" "pie" replace-string
Author: | paldepind |
Mode: | factor |
Date: | Thu, 3 Jan 2013 20:32:01 |
Plain Text |
: replace-string2 ( string match replace -- string' )
'[
[ dup empty? ]
[ _ ?head [ _ % ] [ [ first , ] [ rest ] bi ] if ]
until
] "" make nip ;
New Annotation