473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem with a Regular Expression in C. Need Help!

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
2 1750
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
5
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL,...
11
by: Dimitris Georgakopuolos | last post by:
Hello, I have a text file that I load up to a string. The text includes certain expression like {firstName} or {userName} that I want to match and then replace with a new expression. However,...
10
by: Lee Kuhn | last post by:
I am trying the create a regular expression that will essentially match characters in the middle of a fixed-length string. The string may be any characters, but will always be the same length. In...
6
by: Ludwig | last post by:
Hi, i'm using the regular expression \b\w to find the beginning of a word, in my C# application. If the word is 'public', for example, it works. However, if the word is '<public', it does not...
6
by: deepak_kamath_n | last post by:
Hello, I am relatively new to the world of regex and require some help in forming a regular expression to achieve the following: I have an input stream similar to: Slot: slot1 Description:...
14
by: Chris | last post by:
I need a pattern that matches a string that has the same number of '(' as ')': findall( compile('...'), '42^((2x+2)sin(x)) + (log(2)/log(5))' ) = Can anybody help me out? Thanks for any help!
3
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular...
18
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.