From 487416b67cc3dce20cb32d7b8cf583ca6d413a92 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 24 Apr 1996 01:20:29 +0000 Subject: [PATCH] Add some new procedures for using regular expressions on strings. --- v7/src/edwin/edwin.pkg | 6 +++++- v7/src/edwin/regexp.scm | 42 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/v7/src/edwin/edwin.pkg b/v7/src/edwin/edwin.pkg index 1dab8a622..61c7853a0 100644 --- a/v7/src/edwin/edwin.pkg +++ b/v7/src/edwin/edwin.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: edwin.pkg,v 1.187 1996/04/23 23:23:56 cph Exp $ +$Id: edwin.pkg,v 1.188 1996/04/24 01:20:29 cph Exp $ Copyright (c) 1989-96 Massachusetts Institute of Technology @@ -550,6 +550,10 @@ MIT in each case. |# re-search-string-forward re-search-substring-backward re-search-substring-forward + re-string-match + re-string-search + re-substring-match + re-substring-search re-substitute-registers replace-match search-backward diff --git a/v7/src/edwin/regexp.scm b/v7/src/edwin/regexp.scm index 0c894b412..84e6615f6 100644 --- a/v7/src/edwin/regexp.scm +++ b/v7/src/edwin/regexp.scm @@ -1,8 +1,8 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: regexp.scm,v 1.66 1995/02/02 21:20:02 cph Exp $ +;;; $Id: regexp.scm,v 1.67 1996/04/24 01:20:21 cph Exp $ ;;; -;;; Copyright (c) 1986, 1989-95 Massachusetts Institute of Technology +;;; Copyright (c) 1986, 1989-96 Massachusetts Institute of Technology ;;; ;;; This material was developed by the Scheme project at the ;;; Massachusetts Institute of Technology, Department of @@ -317,7 +317,7 @@ (mark-index end)))) (and index (make-mark group index))))) - + (define (re-match-forward regexp start #!optional end case-fold-search) (let ((end (default-end-mark start end)) (case-fold-search (default-case-fold-search case-fold-search start)) @@ -331,4 +331,38 @@ (mark-index start) (mark-index end)))) (and index - (make-mark group index))))) \ No newline at end of file + (make-mark group index))))) + +(define (re-string-match regexp string #!optional case-fold syntax-table) + (let ((case-fold (if (default-object? case-fold) #f case-fold)) + (syntax-table (if (default-object? syntax-table) #f syntax-table))) + (re-match-string-forward (re-compile-pattern regexp case-fold) + case-fold + syntax-table + string))) + +(define (re-substring-match regexp string start end + #!optional case-fold syntax-table) + (let ((case-fold (if (default-object? case-fold) #f case-fold)) + (syntax-table (if (default-object? syntax-table) #f syntax-table))) + (re-match-substring-forward (re-compile-pattern regexp case-fold) + case-fold + syntax-table + string start end))) + +(define (re-string-search regexp string #!optional case-fold syntax-table) + (let ((case-fold (if (default-object? case-fold) #f case-fold)) + (syntax-table (if (default-object? syntax-table) #f syntax-table))) + (re-search-string-forward (re-compile-pattern regexp case-fold) + case-fold + syntax-table + string))) + +(define (re-substring-search regexp string start end + #!optional case-fold syntax-table) + (let ((case-fold (if (default-object? case-fold) #f case-fold)) + (syntax-table (if (default-object? syntax-table) #f syntax-table))) + (re-search-substring-forward (re-compile-pattern regexp case-fold) + case-fold + syntax-table + string start end))) \ No newline at end of file -- 2.25.1