Method summary | |
---|---|
build-replacement-template | replacement-string |
create-scanner | regex &key case-insensitive-mode multi-line-mode single-line-mode extended-mode destructive |
scan | regex target-string &key start end real-start-pos |
Function summary | |
---|---|
all-matches | regex target-string &key (start 0) (end (length target-string)) |
all-matches-as-strings | regex target-string &key (start 0) (end (length target-string)) sharedp |
build-replacement | replacement-template target-string start end match-start match-end reg-starts reg-ends simple-calls element-type |
parse-tree-synonym | symbol |
print-symbol-info | symbol |
regex-apropos | regex &optional packages &key (case-insensitive t) |
regex-apropos-list | regex &optional packages &key (case-insensitive t) |
regex-replace | regex target-string replacement &key (start 0) (end (length target-string)) preserve-case simple-calls (element-type 'character) |
regex-replace-all | regex target-string replacement &key (start 0) (end (length target-string)) preserve-case simple-calls (element-type 'character) |
replace-aux | target-string replacement pos-list reg-list start end preserve-case simple-calls element-type |
scan-to-strings | regex target-string &key (start 0) (end (length target-string)) sharedp |
(setf parse-tree-synonym) | new-parse-tree symbol |
split | regex target-string &key (start 0) (end (length target-string)) limit with-registers-p omit-unmatched-p sharedp |
string-case-modifier | str from to start end |
Macro summary | |
---|---|
define-parse-tree-synonym | name parse-tree |
do-matches | (match-start match-end regex target-string &optional result-form &key start end) &body body |
do-matches-as-strings | (match-var regex target-string &optional result-form &key start end sharedp) &body body |
do-register-groups | var-list (regex target-string &optional result-form &key start end sharedp) &body body |
do-scans | (match-start match-end reg-starts reg-ends regex target-string &optional result-form &key start end) &body body &environment env |
regex-apropos-aux | (regex packages case-insensitive &optional return-form) &body body |
register-groups-bind | var-list (regex target-string &key start end sharedp) &body body |
create-scanner | regex &key case-insensitive-mode multi-line-mode single-line-mode extended-mode destructive | [Generic function] |
Accepts a regular expression - either as a parse-tree or as a string - and returns a scan closure which will scan strings for this regular expression and a list mapping registers to their names (NIL stands for unnamed ones). The "mode" keyboard arguments are equivalent to the imsx modifiers in Perl. If DESTRUCTIVE is not NIL the function is allowed to destructively modify its first argument (but only if it's a parse tree).
Searches TARGET-STRING from START to END and tries to match REGEX. On success returns four values - the start of the match, the end of the match, and two arrays denoting the beginnings and ends of register matches. On failure returns NIL. REGEX can be a string which will be parsed according to Perl syntax, a parse tree, or a pre-compiled scanner created by CREATE-SCANNER. TARGET-STRING will be coerced to a simple string if it isn't one already. The REAL-START-POS parameter should be ignored - it exists only for internal purposes.
Converts a replacement string for REGEX-REPLACE or REGEX-REPLACE-ALL into a replacement template which is an S-expression.
Like SCAN but returns substrings of TARGET-STRING instead of positions, i.e. this function returns two values on success: the whole match as a string plus an array of substrings (or NILs) corresponding to the matched registers. If SHAREDP is true, the substrings may share structure with TARGET-STRING.
Returns a list containing the start and end positions of all matches of REGEX against TARGET-STRING, i.e. if there are N matches the list contains (* 2 N) elements. If REGEX matches an empty string the scan is continued one position behind this match.
all-matches-as-strings | regex target-string &key (start 0) (end (length target-string)) sharedp | [Function] |
Returns a list containing all substrings of TARGET-STRING which match REGEX. If REGEX matches an empty string the scan is continued one position behind this match. If SHAREDP is true, the substrings may share structure with TARGET-STRING.
split | regex target-string &key (start 0) (end (length target-string)) limit with-registers-p omit-unmatched-p sharedp | [Function] |
Matches REGEX against TARGET-STRING as often as possible and returns a list of the substrings between the matches. If WITH-REGISTERS-P is true, substrings corresponding to matched registers are inserted into the list as well. If OMIT-UNMATCHED-P is true, unmatched registers will simply be left out, otherwise they will show up as NIL. LIMIT limits the number of elements returned - registers aren't counted. If LIMIT is NIL (or 0 which is equivalent), trailing empty strings are removed from the result list. If REGEX matches an empty string the scan is continued one position behind this match. If SHAREDP is true, the substrings may share structure with TARGET-STRING.
Checks whether all words in STR between FROM and TO are upcased, downcased or capitalized and returns a function which applies a corresponding case modification to strings. Returns #'IDENTITY otherwise, especially if words in the target area extend beyond FROM or TO. STR is supposed to be bounded by START and END. It is assumed that (<= START FROM TO END).
build-replacement | replacement-template target-string start end match-start match-end reg-starts reg-ends simple-calls element-type | [Function] |
Accepts a replacement template and the current values from the matching process in REGEX-REPLACE or REGEX-REPLACE-ALL and returns the corresponding string.
replace-aux | target-string replacement pos-list reg-list start end preserve-case simple-calls element-type | [Function] |
Auxiliary function used by REGEX-REPLACE and REGEX-REPLACE-ALL. POS-LIST contains a list with the start and end positions of all matches while REG-LIST contains a list of arrays representing the corresponding register start and end positions.
regex-replace | regex target-string replacement &key (start 0) (end (length target-string)) preserve-case simple-calls (element-type 'character) | [Function] |
Try to match TARGET-STRING between START and END against REGEX and replace the first match with REPLACEMENT. Two values are returned; the modified string, and T if REGEX matched or NIL otherwise.
REPLACEMENT can be a string which may contain the special substrings "\&" for the whole match, "\`" for the part of TARGET-STRING before the match, "\'" for the part of TARGET-STRING after the match, "\N" or "\{N}" for the Nth register where N is a positive integer.
REPLACEMENT can also be a function designator in which case the match will be replaced with the result of calling the function designated by REPLACEMENT with the arguments TARGET-STRING, START, END, MATCH-START, MATCH-END, REG-STARTS, and REG-ENDS. (REG-STARTS and REG-ENDS are arrays holding the start and end positions of matched registers or NIL - the meaning of the other arguments should be obvious.)
Finally, REPLACEMENT can be a list where each element is a string, one of the symbols :MATCH, :BEFORE-MATCH, or :AFTER-MATCH - corresponding to "\&", "\`", and "\'" above -, an integer N - representing register (1+ N) -, or a function designator.
If PRESERVE-CASE is true, the replacement will try to preserve the case (all upper case, all lower case, or capitalized) of the match. The result will always be a fresh string, even if REGEX doesn't match.
ELEMENT-TYPE is the element type of the resulting string.
regex-replace-all | regex target-string replacement &key (start 0) (end (length target-string)) preserve-case simple-calls (element-type 'character) | [Function] |
Try to match TARGET-STRING between START and END against REGEX and replace all matches with REPLACEMENT. Two values are returned; the modified string, and T if REGEX matched or NIL otherwise.
REPLACEMENT can be a string which may contain the special substrings "\&" for the whole match, "\`" for the part of TARGET-STRING before the match, "\'" for the part of TARGET-STRING after the match, "\N" or "\{N}" for the Nth register where N is a positive integer.
REPLACEMENT can also be a function designator in which case the match will be replaced with the result of calling the function designated by REPLACEMENT with the arguments TARGET-STRING, START, END, MATCH-START, MATCH-END, REG-STARTS, and REG-ENDS. (REG-STARTS and REG-ENDS are arrays holding the start and end positions of matched registers or NIL - the meaning of the other arguments should be obvious.)
Finally, REPLACEMENT can be a list where each element is a string, one of the symbols :MATCH, :BEFORE-MATCH, or :AFTER-MATCH - corresponding to "\&", "\`", and "\'" above -, an integer N - representing register (1+ N) -, or a function designator.
If PRESERVE-CASE is true, the replacement will try to preserve the case (all upper case, all lower case, or capitalized) of the match. The result will always be a fresh string, even if REGEX doesn't match.
ELEMENT-TYPE is the element type of the resulting string.
Similar to the standard function APROPOS-LIST but returns a list of all symbols which match the regular expression REGEX. If CASE-INSENSITIVE is true and REGEX isn't already a scanner, a case-insensitive scanner is used.
Auxiliary function used by REGEX-APROPOS. Tries to print some meaningful information about a symbol.
Similar to the standard function APROPOS but returns a list of all symbols which match the regular expression REGEX. If CASE-INSENSITIVE is true and REGEX isn't already a scanner, a case-insensitive scanner is used.
Returns the parse tree the SYMBOL symbol is a synonym for. Returns NIL is SYMBOL wasn't yet defined to be a synonym.
Defines SYMBOL to be a synonm for the parse tree NEW-PARSE-TREE.
Executes BODY with the variables in VAR-LIST bound to the corresponding register groups after TARGET-STRING has been matched against REGEX, i.e. each variable is either bound to a string or to NIL. If there is no match, BODY is _not_ executed. For each element of VAR-LIST which is NIL there's no binding to the corresponding register group. The number of variables in VAR-LIST must not be greater than the number of register groups. If SHAREDP is true, the substrings may share structure with TARGET-STRING.
do-scans | (match-start match-end reg-starts reg-ends regex target-string &optional result-form &key start end) &body body &environment env | [Macro] |
Iterates over TARGET-STRING and tries to match REGEX as often as possible evaluating BODY with MATCH-START, MATCH-END, REG-STARTS, and REG-ENDS bound to the four return values of each match in turn. After the last match, returns RESULT-FORM if provided or NIL otherwise. An implicit block named NIL surrounds DO-SCANS; RETURN may be used to terminate the loop immediately. If REGEX matches an empty string the scan is continued one position behind this match. BODY may start with declarations.
do-matches | (match-start match-end regex target-string &optional result-form &key start end) &body body | [Macro] |
Iterates over TARGET-STRING and tries to match REGEX as often as possible evaluating BODY with MATCH-START and MATCH-END bound to the start/end positions of each match in turn. After the last match, returns RESULT-FORM if provided or NIL otherwise. An implicit block named NIL surrounds DO-MATCHES; RETURN may be used to terminate the loop immediately. If REGEX matches an empty string the scan is continued one position behind this match. BODY may start with declarations.
do-matches-as-strings | (match-var regex target-string &optional result-form &key start end sharedp) &body body | [Macro] |
Iterates over TARGET-STRING and tries to match REGEX as often as possible evaluating BODY with MATCH-VAR bound to the substring of TARGET-STRING corresponding to each match in turn. After the last match, returns RESULT-FORM if provided or NIL otherwise. An implicit block named NIL surrounds DO-MATCHES-AS-STRINGS; RETURN may be used to terminate the loop immediately. If REGEX matches an empty string the scan is continued one position behind this match. If SHAREDP is true, the substrings may share structure with TARGET-STRING. BODY may start with declarations.
do-register-groups | var-list (regex target-string &optional result-form &key start end sharedp) &body body | [Macro] |
Iterates over TARGET-STRING and tries to match REGEX as often as possible evaluating BODY with the variables in VAR-LIST bound to the corresponding register groups for each match in turn, i.e. each variable is either bound to a string or to NIL. For each element of VAR-LIST which is NIL there's no binding to the corresponding register group. The number of variables in VAR-LIST must not be greater than the number of register groups. After the last match, returns RESULT-FORM if provided or NIL otherwise. An implicit block named NIL surrounds DO-REGISTER-GROUPS; RETURN may be used to terminate the loop immediately. If REGEX matches an empty string the scan is continued one position behind this match. If SHAREDP is true, the substrings may share structure with TARGET-STRING. BODY may start with declarations.
Auxiliary macro used by REGEX-APROPOS and REGEX-APROPOS-LIST. Loops through PACKAGES and executes BODY with SYMBOL bound to each symbol which matches REGEX. Optionally evaluates and returns RETURN-FORM at the end. If CASE-INSENSITIVE is true and REGEX isn't already a scanner, a case-insensitive scanner is used.