Basic Regex Question

  • Thread starter Thread starter William Ryan
  • Start date Start date
W

William Ryan

How do I ignore something that's part of what I want to find. For
instance..I have this string [33333333]

I have a regex \]\d*\] to find the whole thing. However, I don't want to
have either of the brackets returned..I want my return value to be 33333333
not [33333333].
Our resident regex guru is out on vacation and I'm stumped.

Thanks,

Bill
 
I have a regex \]\d*\] to find the whole thing. However, I don't want to
have either of the brackets returned..I want my return value to be 33333333
not [33333333].

Group the area by parentes such as \](\d*)\]
 
Peter:

Thanks for the help. I changed it but it's still including the brackets.
I'm obviously messing something up (I'm not very experienced with them yet)

I also tried this (?=[)(\d*)(?=]) and every derivation of the assertions
that I can think of. It stops matching after the first one is found...if I
just do \[(\d*)(?=]) it will return [3333333 b/c I'm not trying to find
anything after that..but if I do it at the beginning, I'm out of gas.

Any Ideas?


Thanks again,

Bill
Peter Theill said:
I have a regex \]\d*\] to find the whole thing. However, I don't want to
have either of the brackets returned..I want my return value to be 33333333
not [33333333].

Group the area by parentes such as \](\d*)\]
 
I have a work around but I know it isn't the right way to do it. If I find
everything with the brackets, and I know that my match there is correct, I
can use that match as my search value and just find successive numbers. But
if I needed something to find ssn's for isntance, 111-11-1111 and didn't
want the hyphens included, this wouldn't work --- I know I'm missing
something b/c these things are too powerful to have to use hacks.

TIA,

Bill
 
Thanks for the help. I changed it but it's still including the brackets.
I'm obviously messing something up (I'm not very experienced with them
yet)

I haven't worked with RegExp on .NET yet, but normally you're able to pick
out the groups explicitly using syntax like:

RegExp.Parse("[3333333]", "\](\d*)\]").GetGroup(1)
 
I'll give it a try, thanks!
Peter Theill said:
Thanks for the help. I changed it but it's still including the brackets.
I'm obviously messing something up (I'm not very experienced with them
yet)

I haven't worked with RegExp on .NET yet, but normally you're able to pick
out the groups explicitly using syntax like:

RegExp.Parse("[3333333]", "\](\d*)\]").GetGroup(1)
 
Thanks Miha!
Miha Markic said:
Hi William,

As a side not, there is a great free utility for toying with regex stuff:
Expresso
http://www12.brinkster.com/ultrapico/ExpressoDownload.htm

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

William Ryan said:
How do I ignore something that's part of what I want to find. For
instance..I have this string [33333333]

I have a regex \]\d*\] to find the whole thing. However, I don't want to
have either of the brackets returned..I want my return value to be 33333333
not [33333333].
Our resident regex guru is out on vacation and I'm stumped.

Thanks,

Bill
 
I just got it up and running. Very cool indeed, thanks again.
Miha Markic said:
Hi William,

As a side not, there is a great free utility for toying with regex stuff:
Expresso
http://www12.brinkster.com/ultrapico/ExpressoDownload.htm

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

William Ryan said:
How do I ignore something that's part of what I want to find. For
instance..I have this string [33333333]

I have a regex \]\d*\] to find the whole thing. However, I don't want to
have either of the brackets returned..I want my return value to be 33333333
not [33333333].
Our resident regex guru is out on vacation and I'm stumped.

Thanks,

Bill
 
Back
Top