scsh-users
[Top] [All Lists]

Problem with ,@ in SREs

To: scsh@zurich.ai.mit.edu
Subject: Problem with ,@ in SREs
From: Ulrich Becker <Ulrich.Becker@informatik.uni-erlangen.de>
Date: Thu, 6 Jul 2000 15:23:46 +0200
Hi,

I have a problem with SREs: I cannot access submatches
of regexps included with ,@. The following example
illustrates my problem:


  ;; define rx1, which matches something like 11:59 and
  ;; delivers the first two digits as submatch
  ;; this works perfectly

  >(define rx1 (rx (: (submatch (= 2 digit)) ":" (= 2 digit))))
  > (regexp-search rx1 "11:59")
  '#{regexp-match}
  > (match:substring (regexp-search rx1 "11:59") 1)
  "11"

  ;; now define rx2 which inclues rx1 with ,@

  (define rx2 (rx (: "bla" ,@rx1 ,"foo")))
  > (regexp-search rx2 "bla11:59foo")
  '#{regexp-match}

  ;; now according to my understanding this should work, but it doesn't:

  > (match:substring (regexp-search rx2 "bla11:59foo") 1)

  Error: exception
         (vector-ref '#(0) 1)

  ;; but strangely enough it works when i first convert rx2 to a posix
  ;; string and vice versa:

  1> (regexp->posix-string rx2)
  ; 4 values
  "bla([0-9]{2}):[0-9]{2}foo"
  2
  1
  '#(1)
  1> (match:substring
        (regexp-search
           (rx (posix-string "bla([0-9]{2}):[0-9]{2}foo"))
           "bla11:59foo")
        1)
  "11"

Now I'm a bit confused...

I am using scsh version 0.52, built and running under
Solaris 2.6.

By the way, any news concerning a new release (I'd love
to use match-cond...)?

Ulrich

--
Ulrich Becker
University of Erlangen-Nuremberg, Germany         phone : +49 9131 85 27275
E-Mail: ub@cs.fau.de                              fax : +49 9131 85 28732

<Prev in Thread] Current Thread [Next in Thread>
  • Problem with ,@ in SREs, Ulrich Becker <=