| Did you know ... | Search Documentation: |
| Send methods |
<->pattern
to a compiled representation in _-compiled_. Normally invoked
automatically by regex->search
when needed.
If the argument is @on,
the pattern is compiled optimised, increasing compilation
time, but reducing search time.
file_pattern represents a common (Unix csh)
file-pattern, translate it into a regular expression representing the
same pattern and associate this using regex->pattern.
The following constructs are mapped:
? .
* .*
[...] [...]
{a,b} \(a\|b\)
The pattern is closed with a’$’sign.
|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.
->search
when @on.->compile’d
on the first call to regex->match
or
regex->search.
After creation the pattern may be changed using
regex->pattern.
If the case_sensitive argument is @off,
searching and matching is caried out ignoring case. See also regex->ignore_case.
|text_buffer|fragment,
start=[int], end=[int]<-match-pattern
regex->replace
is equivalent to regex->register_value:
Object, Value, but in addition to this method expands the special
construct’\digit’with the text of the
corresponding register value.
|text_buffer|fragment,
start=[int], end=[int]<-register_start, regex<-register_end
and
regex<-register_value
may be used to get information on the location of the match.
If end is smaller than start, the search is
executed backwards. The regex<-search
variant returns the regex<-register_start.
See also regex->pattern, regex->match
and regex<-match.
<-register_start <-register_value <-register_end