| Did you know ... | Search Documentation: |
| regex->for_all |
|text_buffer|fragment,
action=code, from=[int], to=[int]
@arg1 The regex object @arg2 The object searched in
After each successful regex->search,
the argument code object
is executed. The next regex->search
is started at regex<-register_end.
If the regex matched an empty string and the string is still empty after
executing the code
object, the search is restarted at
regex<-register_end
+ 1 to avoid a loop.
When from and to are specified, the for_all
is ran only in the specified range.
The code executed may invoke regex->register_value, regex->replace,
etc. to modify the text. The following code replaces all foo
in
bar in string S:
?- send(regex(foo), for_all, S,
message(@arg1, replace, @arg2, bar)).
See also char_array<-split.