From: Frederic Brunel
Subject: Allegro regexp with grouping syntax
Date: 
Message-ID: <lan0nxk1mk.fsf@buzz.in-fusio.com>
Hi,

I'm using the regexp package from Allegro CL and I couldn'd managed to
use the grouping syntax within a regular expression. Here is a sample
of the Allegro's documentation.

 CL-USER: (match-regexp ".*" "foobarbaz")
 T
 "foobarbaz"

 CL-USER: (match-regexp "foo\(.*\)baz "foobarbaz" :return :string)
 NIL

The `:return :string' means that the content of all each grouping
constructs should be returned as multiple sub-strings. Anyway, it
doesn't seems to match my string anymore. I was expecting the function
to return something like:

 T
 "bar"

Here a sample of the Allegro documentation about the grouping syntax:

  \(x\) This grouping syntax matches whatever x matches, and at the
  same time remembers what x matches. There can be up to 9 groups
  defined in a regular expression string. Each group is given a number
  from 1 to 9 based on the order in which they appear in the pattern
  string. When the match is made, the value of each group can be
  returned by the match-regexp function.

-- 
Frederic Brunel
Software Engineer
In-Fusio - Mobile Game Connections

From: Christian Nyb�
Subject: Re: Allegro regexp with grouping syntax
Date: 
Message-ID: <sikk7j1d0dj.fsf@grace.uio.no>
Frederic Brunel <···············@in-fusio.com> writes:

> Hi,
> 
> I'm using the regexp package from Allegro CL and I couldn'd managed to
> use the grouping syntax within a regular expression. Here is a sample
> of the Allegro's documentation.
> 
>  CL-USER: (match-regexp ".*" "foobarbaz")
>  T
>  "foobarbaz"
> 
>  CL-USER: (match-regexp "foo\(.*\)baz "foobarbaz" :return :string)
>  NIL

CL-USER(17): (match-regexp "foo\\(.*\\)baz" "foobarbaz" :return :string)
T
"foobarbaz"
"bar"
CL-USER(18): 

Extra backslashes seem to do the trick.

From http://www.franz.com/support/documentation/6.2/doc/regexp.htm:

	When typing a regular expression in Lisp source code keep in
	mind that in order to represent a backslash in a string
	constant you need two backslashes. The Lisp reader reads
	"foo\+" as "foo+", when what you probably wanted was "foo\\+"
	(where you are putting a backslash in front of the + to remove
	its special meaning so you could match the string foo+.)

-- 
chr
From: Frederic Brunel
Subject: Re: Allegro regexp with grouping syntax
Date: 
Message-ID: <laisykjt4e.fsf@buzz.in-fusio.com>
···@sli.uio.no (Christian Nyb�) writes:
> CL-USER(17): (match-regexp "foo\\(.*\\)baz" "foobarbaz" :return :string)
> T
> "foobarbaz"
> "bar"
> CL-USER(18): 
> 
> Extra backslashes seem to do the trick.

  Thanx for your answer, I've missed this information from the
  documentation.

-- 
Frederic Brunel
Software Engineer
In-Fusio - Mobile Game Connections