1 (eval-when (:compile-toplevel
:load-toplevel
:execute
)
14 (defvar *case-fold-search
* nil
)
17 (defun string-match (pattern string
18 &optional
(start 0) end
)
19 "Search the string STRING for the first pattern that matches the
20 regexp PATTERN. The syntax used for the pattern is specified by
21 SYNTAX. The search may start in the string at START and ends at END,
22 which default to 0 and the end of the string.
24 If there is a match, returns the index of the start of the match and
25 an array of match-data. If there is no match, -1 is returned and
31 (regexp:match pattern string
:start start
:end end
32 :case-insensitive
*case-fold-search
*)
33 #+case-fold-search-not
34 (regexp:match pattern string
:start start
:end end
35 :case-sensitive
(not *case-fold-search
*))
37 (setf *match-data
* result
)
39 (regexp:match-start
(first result
))
42 (defun string-match (pattern string
43 &optional
(start 0) end
)
44 "Search the string STRING for the first pattern that matches the
45 regexp PATTERN. The syntax used for the pattern is specified by
46 SYNTAX. The search may start in the string at START and ends at END,
47 which default to 0 and the end of the string.
49 If there is a match, returns the index of the start of the match and
50 an array of match-data. If there is no match, -1 is returned and
53 (let* ((compiled-pattern (regexp:regexp-compile pattern
54 #+case-fold-search
*case-fold-search
*
55 #+case-fold-search-not
(not *case-fold-search
*)
59 (regexp:regexp-exec compiled-pattern string
60 :start start
:end end
))))
61 (setf *match-data
* result
)
63 (regexp:match-start
(first result
))
66 (defun match-beginning (index &optional
(match-data *match-data
*))
67 (if (and match-data
(< index
(length match-data
)))
68 (regexp:match-start
(elt match-data index
))
71 (defun match-end (index &optional
(match-data *match-data
*))
72 (if (and match-data
(< index
(length match-data
)))
73 (regexp:match-end
(elt match-data index
))