s:split-on-string, s:replace

FossilOrigin-Name: 013fcbf0fe7e0f8955f7e7d417422bcdd60bd431e4d0f41f0f9a4087d00997f5
This commit is contained in:
crc 2017-11-09 19:28:01 +00:00
parent fd20b76fc8
commit c2005b0ea6
4 changed files with 14 additions and 2 deletions

File diff suppressed because one or more lines are too long

View file

@ -895,6 +895,16 @@ located.
~~~
:s:split (sc-ss)
dup-pair s:index-of nip dup-pair s:left [ + ] dip ;
:s:split-on-string (ss-ss)
dup-pair s:index-of-string n:inc nip dup-pair s:left [ + ] dip ;
{{
'L var
---reveal---
:s:replace (sss-s)
over s:length !L [ s:split-on-string swap @L + ] dip s:prepend s:append ;
}}
~~~
Ok, This is a bit of a hack, but very useful at times.

BIN
ngaImage

Binary file not shown.

View file

@ -289,6 +289,8 @@ s:reverse s-s - - Reverse the order of ASCII characters in a string. class:wor
s:right sn-s - - Return a new string containing the specified number of characters from the right side of the string. class:word {n/a} {n/a} s all
s:skip - - - Internal helper function used to skip over a string in a definition. class:word {n/a} {n/a} s all
s:split sc-ss - - Split a string on the first occurrance of the specified character. class:word {n/a} {n/a} s all
s:split-on-string ss-ss - - Split a string on the first occurrance of the specified string. class:word {n/a} {n/a} s all
s:replace sss-s - - Replace the first instance of s2 in s1 with s3. class:word {n/a} {n/a} s all
s:substr sfl-s - - Extract a substring from the specified string. This will take the characters starting at `f` and extend `l` characters in length. class:word {n/a} {n/a} s all
s:temp s-s - - Move a string into the temporary string buffers. class:word {n/a} {n/a} s all
s:to-float s- - -F Convert a string representation into a floating point value. class:word {n/a} {n/a} s rre

1 * nn-n - - Multiply `n1` by `n2` and return the result. class:primitive {n/a} {n/a} global all
289 s:right sn-s - - Return a new string containing the specified number of characters from the right side of the string. class:word {n/a} {n/a} s all
290 s:skip - - - Internal helper function used to skip over a string in a definition. class:word {n/a} {n/a} s all
291 s:split sc-ss - - Split a string on the first occurrance of the specified character. class:word {n/a} {n/a} s all
292 s:split-on-string ss-ss - - Split a string on the first occurrance of the specified string. class:word {n/a} {n/a} s all
293 s:replace sss-s - - Replace the first instance of s2 in s1 with s3. class:word {n/a} {n/a} s all
294 s:substr sfl-s - - Extract a substring from the specified string. This will take the characters starting at `f` and extend `l` characters in length. class:word {n/a} {n/a} s all
295 s:temp s-s - - Move a string into the temporary string buffers. class:word {n/a} {n/a} s all
296 s:to-float s- - -F Convert a string representation into a floating point value. class:word {n/a} {n/a} s rre