Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegEx question 1

Status
Not open for further replies.

grande

Programmer
Feb 14, 2005
657
CA
Hi guys,

I'm having a bit of a RegEx problem, and I was hoping you could help.

I have the following code
Code:
ArrayList strArray = new ArrayList();
string strPattern = @"\(.*\)";
foreach (Match m in Regex.Matches(str, strPattern))
    strArray.Add(m.ToString());

I'm trying to get the data out of the brackets in a string that looks like this:
1/4" (.250") - 11/32" (.344")

But what I'm getting is this:
(.250") - 11/32" (.344")

I remember, when first learning about regular expressions in Perl, lo many years ago, there was a way to make the expression "Not Greedy," and only go to the first instance of the character, not the last one.

Can anyone help me out?

-------------------------
Call me barely Impressive Captain.
 
I'm not sure if I made this clear. What I'd like to get out is an array with two elements:
.250"
.344"

Sorry if my first post was convoluded.


-------------------------
Call me barely Impressive Captain.
 
Yes, that's exactly it. Thank you!

-------------------------
Call me barely Impressive Captain.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top