summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-16 09:46:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-16 09:46:14 -0800
commitf16aaf441c112f0e6382b77ebdcd585d8c531580 (patch)
treece3041d1395f7260bd698230098beffc778ca952 /txr.1
parent338f97b5a32a038a7cb21b8045a72412dbe4bfd6 (diff)
downloadtxr-f16aaf441c112f0e6382b77ebdcd585d8c531580.tar.gz
txr-f16aaf441c112f0e6382b77ebdcd585d8c531580.tar.bz2
txr-f16aaf441c112f0e6382b77ebdcd585d8c531580.zip
scan-until-match, count-until-match: new functions.
* regex.c (scan_until_common): New static function, made from read_until_match. (read_until_match): Now just wrapper for scan_until_common. (scan_until_match, count_until_match): New functions. (regex_init): Registered new intrinsics scan-until-match and count-until-match. * regex.h (read_until_match, scan_until_match): Declared. * txr.1: Documented.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.148
1 files changed, 46 insertions, 2 deletions
diff --git a/txr.1 b/txr.1
index 41d1568f..f915b133 100644
--- a/txr.1
+++ b/txr.1
@@ -40197,8 +40197,8 @@ If
matches the stream before any characters are accumulated,
then an empty string is returned.
-If the stream ends or an error occurs before any characters
-are accumulated, the function returns
+If the stream ends or an non-exception-throwing error occurs before any
+characters are accumulated, the function returns
.codn nil .
When the accumulation of characters terminates by a match on
@@ -40209,6 +40209,50 @@ removed from the stream. If
is true, that matching text is included in
the returned string. Otherwise, it is discarded.
+.coNP Functions @ scan-until-match and @ count-until-match
+.synb
+.mets (scan-until-match < regex <> [ stream ])
+.mets (count-until-match < regex <> [ stream ])
+.syne
+.desc
+The functions
+.code scan-until-match
+and
+.code count-until-match
+read characters from
+.meta stream
+until a match occurs in the stream for regular expression
+.metn regex ,
+the stream runs out of characters, or an error occurs.
+
+If the stream runs out of characters, or a non-exception-throwing error
+occurs, before a match for
+.meta regex
+is identified, these functions return
+.codn nil .
+
+If a match for
+.meta regex
+occurs in
+.metn stream ,
+then
+.code count-until-match
+returns the number of characters that were read and discarded prior to
+encountering the first matching character.
+In the same situation, the
+.code scan-until-match
+function returns a
+.code cons
+cell whose
+.code car
+holds the count of discarded characters, that being the same value as what
+would be returned by
+.codn count-until-match ,
+and whose
+.code cdr
+holds a character string that comprises the text matched by
+.metn regex .
+
.coNP Functions @, m^$ @ m^ and @ m$
.synb
.mets (m^$ < regex <> [ position ] << string )