By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,238 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,238 IT Pros & Developers. It's quick & easy.

Problem with a Regular Expression in C. Need Help!

P: n/a
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.
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mike Andrews wrote:
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 '\\'?

Nov 13 '05 #2

P: n/a
mi***@farpointer.net (Mike Andrews) wrote:
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
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.