Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem with a Regular Expression in C. Need Help!

Mike Andrews
Guest
 
Posts: n/a
#1: Nov 13 '05
Guys,

I've got a regular expression that will just not work. I can't get it
work properly and I would like to see if someone out there can tell me
if I'm doing this wrong, or if there is a problem with the regex C
library for linux.

Here's my regular expression:

[<|\[]+(a|input|select|option|textarea|form|frame|iframe |area|base|link|icon:[\w]*)\s*(([^<>]|[^\[\]])*)[>|\]]


Now, this fails to match:
<icon:set name="bob" value="bob">

However, when I use this regular expression:

[<|\[]+(a|input|select|option|textarea|form|frame|iframe |area|base|link|icon:[\w]*)\s*(([^<>]|[^\[\]])*)[>]

it matches correctly. All I did was remove the |\] from the ending
character class. I really don't understand what I'm missing here.
If anyone has any suggestions, I would really appreciate it.

Thanks,
Mike Andrews
Farpointer Technologies, Inc.

Jeff Rodriguez
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Problem with a Regular Expression in C. Need Help!


Mike Andrews wrote:[color=blue]
> Guys,
>
> I've got a regular expression that will just not work. I can't get it
> work properly and I would like to see if someone out there can tell me
> if I'm doing this wrong, or if there is a problem with the regex C
> library for linux.
>
> Here's my regular expression:
>
> [<|\[]+(a|input|select|option|textarea|form|frame|iframe |area|base|link|icon:[\w]*)\s*(([^<>]|[^\[\]])*)[>|\]]
>
>
> Now, this fails to match:
> <icon:set name="bob" value="bob">
>
> However, when I use this regular expression:
>
> [<|\[]+(a|input|select|option|textarea|form|frame|iframe |area|base|link|icon:[\w]*)\s*(([^<>]|[^\[\]])*)[>]
>
> it matches correctly. All I did was remove the |\] from the ending
> character class. I really don't understand what I'm missing here.
> If anyone has any suggestions, I would really appreciate it.
>
> Thanks,
> Mike Andrews
> Farpointer Technologies, Inc.[/color]

Perhaps you are forgetting to escape your backslashes? i.e. '\' should be '\\'?

Richard Bos
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Problem with a Regular Expression in C. Need Help!


mikea@farpointer.net (Mike Andrews) wrote:
[color=blue]
> I've got a regular expression that will just not work.[/color]

And what makes you think regexes are part of ISO C?
[color=blue]
> I can't get it
> work properly and I would like to see if someone out there can tell me
> if I'm doing this wrong, or if there is a problem with the regex C
> library for linux.[/color]

If there is, you'll find out about it in comp.unix.programmer.

Richard
Closed Thread