473,503 Members | 2,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regular Expression problem

I want to search, in the middle of some other stuff, for:
either an "A" _or_ one or two spaces _or_ nothing.

i.e. my text can be any of:
xxxxAxxxx
xxxx xxxx
xxxx xxxx
xxxxxxxx

Logically, I'd put A{0,2}|/s{0,2} in there, but it really doesn't like
that.

Any suggestions? Or better places to look?

Cheers,

Andy D

Nov 17 '05 #1
2 937
Personally, when it comes to regular expressions, I suck.

You may want to try playing with The Regulator:

http://sourceforge.net/projects/regulator/

It's a little rough around the edges, but I've found it an excellent tool
for helping me to build working regular expressions.

Hope you find it helpful.

Pete

"Andrew Ducker" <an****@ducker.org.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I want to search, in the middle of some other stuff, for:
either an "A" _or_ one or two spaces _or_ nothing.

i.e. my text can be any of:
xxxxAxxxx
xxxx xxxx
xxxx xxxx
xxxxxxxx

Logically, I'd put A{0,2}|/s{0,2} in there, but it really doesn't like
that.

Any suggestions? Or better places to look?

Cheers,

Andy D

Nov 17 '05 #2
Hi Andrew,

[A]{1}|[\s]{1,2}

NOTE: You can't match *nothing.* Everything matches nothing.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Andrew Ducker" <an****@ducker.org.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I want to search, in the middle of some other stuff, for:
either an "A" _or_ one or two spaces _or_ nothing.

i.e. my text can be any of:
xxxxAxxxx
xxxx xxxx
xxxx xxxx
xxxxxxxx

Logically, I'd put A{0,2}|/s{0,2} in there, but it really doesn't like
that.

Any suggestions? Or better places to look?

Cheers,

Andy D

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3135
by: Harry | last post by:
Hi there, does anyone know how I can build a regular expression e.g. for the string.search() function on runtime, depending on the content of variables? Should be something like this: var...
11
5350
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,...
3
3199
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
7
3794
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
9
3338
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
3
3316
by: LordHog | last post by:
Hello all, I am attempting to create a small scripting application to be used during testing. I extract the commands from the script file I was going to tokenize the each line as one of the...
25
5128
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
5
3778
by: shawnmkramer | last post by:
Anyone every heard of the Regex.IsMatch and Regex.Match methods just hanging and eventually getting a message "Requested Service not found"? I have the following pattern: ^(?<OrgCity>(+)+),...
1
2090
by: sunil | last post by:
Hi, Am writing one C program for one of my module and facing one problem with the regular expression functions provided by the library libgen.h in solaris. In this library we are having two...
1
1662
by: Shawn B. | last post by:
Greetings, I'm using a custom WebBrowser control: http://www.codeproject.com/KB/miscctrl/csEXWB.aspx When I get the DocumentSource of a web page I browsed, and run a regular expression...
0
7204
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
7282
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
7464
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...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.