06-20-07 06:26 PM
On Jun 19, 7:23 am, bpatton <bpat...@ti.com> wrote:
> I'm writing in c
> using regex.h
> on a PC.
> using gcc
> using cygwin.
> Here is my string I'm looking for :
> COMMENT = "2A3: ACTIVE perpendicular width where adjacent space i
s
> ACTIVE space >= 455 = 130"
>
> Here's where I'v compiled the regex.\ that works
> if (regcomp(&rex_comm,"\\s*COMMENT\\s*",REG_EXTENDED|REG_NOSUB|
> REG_ICASE) != 0) {
> ...
>
> }
>
> target PERL style regular expression : ^\\s*COMMENT\\s*=\\s*\"
>
> fails with : ^\\s*COMMENT\\s*
> fails with : \\s*COMMENT\\s*\\=
> fails with : \\s*COMMENT\\s*[=]
>
> I've tried using Regex Coach, but it deals with PERL class regexp and
> it works fine.
This style of regular expression doesn't use perl-style escape
sequences like \s and \w. Instead there are special character classes
such as [:space:] that you can use. So for your example the following
would work: "[:space:]*COMMENT[:space:]*"
See http://www.opengroup.org/onlinepubs...799/xbd/re.html
[ Post a follow-up to this message ]
|