From: skibud2
Subject: clisp regexp module
Date: 
Message-ID: <1164589779.760794.150440@14g2000cws.googlegroups.com>
I am trying to do number pattern matching with extended regular
expressions. The pattern that I am using is \d. For some reason this is
not working in the clisp regular expression module. I have escaped the
slash (like \\d) and that doesn't work either. \w does seem to work. Is
there something that I am missing?

Mike

examples:

>(regexp:match "\\w+" "april 1999" :extended t)
#S(regexp:match :start 0 :end 5)

>(regexp:match "\\d+" "april 1999" :extended t)
<---- returns nothing

>(regexp:match "[0-9]+" "april 1999" :extended t)
#S(regexp:match :start 6 :end 10)

From: Wolfram Fenske
Subject: Re: clisp regexp module
Date: 
Message-ID: <1164595924.139349.125620@f16g2000cwb.googlegroups.com>
"skibud2" <·············@gmail.com> writes:

> I am trying to do number pattern matching with extended regular
> expressions. The pattern that I am using is \d. For some reason this is
> not working in the clisp regular expression module. I have escaped the
> slash (like \\d) and that doesn't work either. \w does seem to work. Is
> there something that I am missing?

The manual, apparently.  In section 32.5. POSIX Regular Expressions
[1] it says

  The "REGEXP" module implements the POSIX regular expressions by
  calling the standard C system facilities. The syntax of these
  regular expressions [2] is described in many places, such as your
  local <regex.h> manual and Emacs info pages.

Using Posix syntax, your example

  (regexp:match "\\d+" "april 1999" :extended t)

becomes

  (regexp:match "[[:digit:]]+" "april 1999" :extended t)

Clisp also has a PCRE (perl-compatible regular expressions) module
[3] if you build it with PCRE-support.  This should give you the
regular expression syntax you want.


Footnotes:
[1]  <http://clisp.cons.org/impnotes.html#regexp-mod>

[2]  In the online version, this is a link to

<http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap09.html>.

[3]  <http://clisp.cons.org/impnotes.html#pcre>

--
Wolfram Fenske

A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
From: skibud2
Subject: Re: clisp regexp module
Date: 
Message-ID: <1164596878.436633.27140@l39g2000cwd.googlegroups.com>
You are correct, POSIX regular expressions imply that the \d should
work. However it doesn't. I am installing a newer version of clisp with
pcre. Hopefully that will do what I expect.

Thanks,

Mike


Wolfram Fenske wrote:
> "skibud2" <·············@gmail.com> writes:
>
> > I am trying to do number pattern matching with extended regular
> > expressions. The pattern that I am using is \d. For some reason this is
> > not working in the clisp regular expression module. I have escaped the
> > slash (like \\d) and that doesn't work either. \w does seem to work. Is
> > there something that I am missing?
>
> The manual, apparently.  In section 32.5. POSIX Regular Expressions
> [1] it says
>
>   The "REGEXP" module implements the POSIX regular expressions by
>   calling the standard C system facilities. The syntax of these
>   regular expressions [2] is described in many places, such as your
>   local <regex.h> manual and Emacs info pages.
>
> Using Posix syntax, your example
>
>   (regexp:match "\\d+" "april 1999" :extended t)
>
> becomes
>
>   (regexp:match "[[:digit:]]+" "april 1999" :extended t)
>
> Clisp also has a PCRE (perl-compatible regular expressions) module
> [3] if you build it with PCRE-support.  This should give you the
> regular expression syntax you want.
>
>
> Footnotes:
> [1]  <http://clisp.cons.org/impnotes.html#regexp-mod>
>
> [2]  In the online version, this is a link to
>
> <http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap09.html>.
>
> [3]  <http://clisp.cons.org/impnotes.html#pcre>
>
> --
> Wolfram Fenske
>
> A: Yes.
> >Q: Are you sure?
> >>A: Because it reverses the logical flow of conversation.
> >>>Q: Why is top posting frowned upon?
From: Wolfram Fenske
Subject: Re: clisp regexp module
Date: 
Message-ID: <1164601254.605060.288070@h54g2000cwb.googlegroups.com>
"skibud2" <·············@gmail.com> writes:

[fixed quoting order]

> Wolfram Fenske wrote:
>> "skibud2" <·············@gmail.com> writes:
>>
>> > I am trying to do number pattern matching with extended regular
>> > expressions. The pattern that I am using is \d. For some reason this is
>> > not working in the clisp regular expression module. I have escaped the
>> > slash (like \\d) and that doesn't work either. \w does seem to work. Is
>> > there something that I am missing?
>>
>> The manual, apparently.  In section 32.5. POSIX Regular Expressions
>> [1] it says
>>
>>   The "REGEXP" module implements the POSIX regular expressions by
>>   calling the standard C system facilities. The syntax of these
>>   regular expressions [2] is described in many places, such as your
>>   local <regex.h> manual and Emacs info pages.
>>
>> Using Posix syntax, your example
>>
>>   (regexp:match "\\d+" "april 1999" :extended t)
>>
>> becomes
>>
>>   (regexp:match "[[:digit:]]+" "april 1999" :extended t)
>>
>> Clisp also has a PCRE (perl-compatible regular expressions) module
>> [3] if you build it with PCRE-support.  This should give you the
>> regular expression syntax you want.
>
> You are correct, POSIX regular expressions imply that the \d should
> work. However it doesn't.

What?  When did I say that?  Posix regular expressions know nothing
about \d and you would know that if you had read the website about
Posix regular expression syntax that one of my footnotes pointed to.
And even if you didn't read it, this part of my posting should have
tipped you off:

> Using Posix syntax, your example
>
>   (regexp:match "\\d+" "april 1999" :extended t)
>
> becomes
>
>   (regexp:match "[[:digit:]]+" "april 1999" :extended t)

It says (quite clearly, IMO) that instead of "\\d+" (which would be
Perl regular expression syntax) you have to use "[[:digit:]]+" (which
is the equivalent in Posix regular expression syntax).

> I am installing a newer version of clisp with pcre. Hopefully that
> will do what I expect.

You should do that.  And while you're at it, learn how to read!  I
suggest you start with Usenet postings and work your way up to
manuals.

--
Wolfram Fenske

A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
From: Pascal Bourguignon
Subject: Re: clisp regexp module
Date: 
Message-ID: <87psb9cyi4.fsf@thalassa.informatimago.com>
"skibud2" <·············@gmail.com> writes:

> You are correct, POSIX regular expressions imply that the \d should
> work. However it doesn't. 

specifications SUSv3...
Moreover, I've never seen any mention of \d in the POSIX

  0

prints:

  man 7 regex 2>/dev/null | grep -c -e '\\d'

On my system:

>> A: Yes.
>> >Q: Are you sure?
>> >>A: Because it reverses the logical flow of conversation.
>> >>>Q: Why is top posting frowned upon?

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

ATTENTION: Despite any other listing of product contents found
herein, the consumer is advised that, in actuality, this product
consists of 99.9999999999% empty space.
From: skibud2
Subject: Re: clisp regexp module
Date: 
Message-ID: <1164596881.744868.176680@45g2000cws.googlegroups.com>
You are correct, POSIX regular expressions imply that the \d should
work. However it doesn't. I am installing a newer version of clisp with
pcre. Hopefully that will do what I expect.

Thanks,

Mike


Wolfram Fenske wrote:
> "skibud2" <·············@gmail.com> writes:
>
> > I am trying to do number pattern matching with extended regular
> > expressions. The pattern that I am using is \d. For some reason this is
> > not working in the clisp regular expression module. I have escaped the
> > slash (like \\d) and that doesn't work either. \w does seem to work. Is
> > there something that I am missing?
>
> The manual, apparently.  In section 32.5. POSIX Regular Expressions
> [1] it says
>
>   The "REGEXP" module implements the POSIX regular expressions by
>   calling the standard C system facilities. The syntax of these
>   regular expressions [2] is described in many places, such as your
>   local <regex.h> manual and Emacs info pages.
>
> Using Posix syntax, your example
>
>   (regexp:match "\\d+" "april 1999" :extended t)
>
> becomes
>
>   (regexp:match "[[:digit:]]+" "april 1999" :extended t)
>
> Clisp also has a PCRE (perl-compatible regular expressions) module
> [3] if you build it with PCRE-support.  This should give you the
> regular expression syntax you want.
>
>
> Footnotes:
> [1]  <http://clisp.cons.org/impnotes.html#regexp-mod>
>
> [2]  In the online version, this is a link to
>
> <http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap09.html>.
>
> [3]  <http://clisp.cons.org/impnotes.html#pcre>
>
> --
> Wolfram Fenske
>
> A: Yes.
> >Q: Are you sure?
> >>A: Because it reverses the logical flow of conversation.
> >>>Q: Why is top posting frowned upon?