Regular Expression - how do i exclude brackets from result

Hi, new to regular expressions. Basically a non-programmer.
Please help me with the following:

This is my string:
expertsExchange(269087);">

From this I need just the number 269087 and nothing else.

I have tried my best but I always end up with (269087)

Thanks for your help in advance.

greazedlightningAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

xRalfCommented:
Try this .*(\d+).*

Capturing group 1 should contain your number.
0
greazedlightningAuthor Commented:
I tried this:

expertsExchange(.*(\d+).*);">

and got this:

Match count: 1
Match[1][0]=expertsExchange(269087);">
Match[1][1]=(269087)
Match[1][2]=7
0
silemoneCommented:
you can use split and separate delimit with a delimit array that includes '(',')'

this would mean that your number would be array item 1;
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

silemoneCommented:
0
silemoneCommented:
          Just change to vb.net or let me know which language you are writing code in.
 
           string input = @"expertsExchange(269087)";
            char[] delimiters = { '(', ')' };
            string[] parts1 = input.Split(delimiters);
0
käµfm³d 👽Commented:
Depending on your language, you should be able to simply use:

\d+

Open in new window

0
silemoneCommented:
well grouping definitely works, but this is writen in C#:

Regex r = new Regex(@"([a-zA-Z\(]*)([0-9]*)([a-zA-Z)]*)(.)*");
Match m = r.Match("expertsExchange(269087);\">");
Console.WriteLine("Tag: {0}, InnerText: {1}", m.Groups[1].Value, m.Groups[2].Value);
0
Todd GerbertIT ConsultantCommented:
I'm with kaufmed - http:#a35234515

No need to over-think it, that pattern will match any group of 1 or more consecutive decimal digits, and since there's only one spot where numbers occur in your string, and they're what you're interested in, voila!
0
Todd GerbertIT ConsultantCommented:
(Don't gimme any points for that comment above, I just wanted to reinforce kaufmed's as your best option)
0
käµfm³d 👽Commented:
No need to over-think it...


Yeah, I'm lazy and I don't like to type, so the shorter the better   ; )
0
greazedlightningAuthor Commented:
@silemone

I need this for jmeter which uses Apache Jakarta ORO
http://jakarta.apache.org/jmeter/usermanual/regular_expressions.html
http://jakarta.apache.org/oro/

This is similar to PERL.

Can you whip this up in perl?
0
silemoneCommented:
I know some perl...try -
$phrase=~ m/([a-zA-Z\(]+):(\d+):([a-zA-Z)]+)(.)*/;
$numExtracted = $2;

0
silemoneCommented:
Corrected

I know some perl...try -
$phrase="expertsExchange(269087);\">"
$phrase= ~ m/([a-zA-Z\(]+):([0-9]+):([a-zA-Z\)]+)(.)*/;
$numExtracted = $2;
0
käµfm³d 👽Commented:
Funny, even after looking over the documentation, I don't see anything to indicate the pattern I offered wouldn't work. It even worked in their online tester.
untitled.PNG
0
käµfm³d 👽Commented:
I should note that it will only succeed for a "contains" search and not a "matches" search. You would need to modify the pattern a bit for a "matches" search (see below).


Result will be in 1st capture group.
.*?(\d+).*

Open in new window

untitled.PNG
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
greazedlightningAuthor Commented:
Brilliantly done kaufmed. Simple and spot on. This is my first question on experts exchange.
Can you direct me toward some easy to understand tutorials on regex?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.