| |||||||||||
| Replace substrings
substitute(+regexp, +string, +substitution, -result)substitute/4 replaces in "string" the substring defined by "regexp" with "substitution". The modified string is returned in "result"
Argumentsregexp atom string atom substitution atom result atom
Examplese.g. to exchange the position of words
substitute('(%w+) (%w+)', 'one two', '%2 %1', L).
==> L = 'two one'
Whatever is bracketed is assigned to a term. Whatever is bracketed by the from left to right i-th opening bracket is assigned to the i-th term. Bracketed terms can be referenced in substitute/4 and substitute_all/4 with %1...%9 in the substitute expression.
Standard
This predicate is not part of the ISO-Prolog Standard.
See alsoregular expression, match/2/3, match_all/3, substitute/4, substitute_all/4, split/2/3, chop/2, get_line/1/2, | |||||||||||
| |||||||||||
| Back> |
|