regex.scm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ;;; Regular expressions
  2. ;;; Copyright (C) 2024 David Thompson <dave@spritely.institute>
  3. ;;;
  4. ;;; Licensed under the Apache License, Version 2.0 (the "License");
  5. ;;; you may not use this file except in compliance with the License.
  6. ;;; You may obtain a copy of the License at
  7. ;;;
  8. ;;; http://www.apache.org/licenses/LICENSE-2.0
  9. ;;;
  10. ;;; Unless required by applicable law or agreed to in writing, software
  11. ;;; distributed under the License is distributed on an "AS IS" BASIS,
  12. ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. ;;; See the License for the specific language governing permissions and
  14. ;;; limitations under the License.
  15. ;;; Commentary:
  16. ;;;
  17. ;;; Regular expressions.
  18. ;;;
  19. ;;; Code:
  20. (define-module (ice-9 regex)
  21. #:use-module ((hoot regexps)
  22. #:select (regexp-match?
  23. regexp-match-string
  24. regexp-match-start
  25. regexp-match-end
  26. regexp-match-count
  27. regexp-match-substring
  28. regexp-match-prefix
  29. regexp-match-suffix))
  30. #:export (string-match)
  31. #:re-export (regexp-match?
  32. (regexp-match-string . match:string)
  33. (regexp-match-start . match:start)
  34. (regexp-match-end . match:end)
  35. (regexp-match-count . match:count)
  36. (regexp-match-substring . match:substring)
  37. (regexp-match-prefix . match:prefix)
  38. (regexp-match-suffix . match:suffix)))
  39. (define* (string-match pattern str #:optional (start 0))
  40. (regexp-exec (make-regexp pattern) str start))