Problem with a Regular Expression in C. Need Help!

M

Mike Andrews

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.
 
R

Richard Bos

I've got a regular expression that will just not work.

And what makes you think regexes are part of ISO C?
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.

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

Richard
 
J

Jeff Rodriguez

Mike said:
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.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top