473,503 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function to match parenthesis '(' and ')'

I need a simple function that can match the number of beginning and ending
parenthesis in an expression. Here's a sample expression:

( ( "john" ) and ( "jane" ) and ( "joe" ) )

Does .NET have something built-in that can accomplish this, or do I have to
write my own parser? I don't want to reinvent the wheel if possible.

Nov 21 '05 #1
2 1491
Steve,

Text.RegularExpressions.Regex

http://msdn.microsoft.com/library/de...classtopic.asp

RegexLib
http://www.regexlib.com/Default.aspx

Expresso
http://www.ultrapico.com/Expresso.htm

By the way, I hate it to use every expression so this one too, however
sometimes there are no good alternatives.

I hope this helps a little bit?

Cor
Nov 21 '05 #2
Steve,

I'm not sure if this is what you want, but check out the "balancing groups"
construction in .NET regular expressions. This feature can be used to search
for matching parenthesis, but it is a bit arcane. It allows named captures
to be manipulated on a push-down/pop-up stack. It can also be used to find
matching HTML tags or any other nested construct.

If you download Expresso (http://ultrapico.com), as suggested by Cor
Ligthert, load the Tutorial and select example number 44 from the regular
expression library. It will seach for a left parenthesis and then capture
all the text up to the matching right parenthesis.

This feature is very poorly documented in the Microsoft documentation. It is
discussed in some detail in Jeffrey Friedl's excellent book. Chapter 9 of
that book is available on line. See pat 430 for the section on "Matching
Nested Constructs".

http://www.oreilly.com/catalog/regex2/chapter/ch09.pdf

I hope this helps.

Jim

"Steve Kirsch" <te**@test.com> wrote in message
news:e$****************@TK2MSFTNGP10.phx.gbl...
I need a simple function that can match the number of beginning and ending
parenthesis in an expression. Here's a sample expression:

( ( "john" ) and ( "jane" ) and ( "joe" ) )

Does .NET have something built-in that can accomplish this, or do I have
to
write my own parser? I don't want to reinvent the wheel if possible.

Nov 21 '05 #3

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

Similar topics

4
3101
by: marco | last post by:
Hello, I'm putting together a php webpage which is parsing my (.html) bookmarks list. I want to give them a new lay-out with php and CSS. My question is: How can I make a function that counts...
0
963
by: chenyu468 | last post by:
Hi, I am using (vc++) of vs.net 2003 for development. In the source code, there are too many right parenthesis in one section. I want to test which left parenthesis for one specified parenthesis....
38
15911
by: Steve Kirsch | last post by:
I need a simple function that can match the number of beginning and ending parenthesis in an expression. Here's a sample expression: ( ( "john" ) and ( "jane" ) and ( "joe" ) ) Does .NET have...
13
1678
by: Jake Barnes | last post by:
I saw this sentence: "The last stage of variable instantiation is to create named properties of the Variable object that correspond with all the local variables declared within the function." ...
6
2701
by: EXI-Andrews, Jack | last post by:
the '*' and '+' don't seem to be greedy.. they will consume less in order to match a string: ('aa', 'ab') this is the sort of behaviour i'd expect from '(a+?)(ab)' a+ should greedily...
7
3183
by: VK | last post by:
I was getting this effect N times but each time I was in rush to just make it work, and later I coudn't recall anymore what was the original state I was working around. This time I nailed the...
7
8099
by: Laurent Pointal | last post by:
on win32] Given the following: 45 .... (<generator object at 0x00A79788>,) .... File "<stdin>", line 1 SyntaxError: invalid syntax
19
3153
by: konrad Krupa | last post by:
I'm not expert in Pattern Matching and it would take me a while to come up with the syntax for what I'm trying to do. I hope there are some experts that can help me. I'm trying to match...
0
7193
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
7316
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
7449
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
5562
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,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
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
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
371
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.