re-replace ( string regexp replacement -- result ) (original) (raw)
re-replace ( string regexp replacement -- result )
Regular expressions » Matching operations with regular expressions
Prev: | re-split ( string regexp -- seq ) |
---|---|
Next: | re-replace-with ( string regexp quot: ( slice -- replacement ) -- result ) |
Vocabulary
regexp
Inputs
string | a string |
---|---|
regexp | a regexp |
replacement | a string |
Outputs
result | a string |
---|
Word description
Replaces substrings which match the input regexp with the given replacement text. The boundaries of the substring are chosen by the strategy used by all-matching-slices.
Examples
USING: prettyprint regexp ; "python is pythonic" R/ python/ "factor" re-replace .
"factor is factoric"
See also
re-replace-with
Definition
USING: kernel regexp.private sequences sequences.private ;
: re-replace ( string regexp replacement -- result )
[ [ subseq-unsafe ] (re-split) ] dip join ;