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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turn gredy matching off

Status
Not open for further replies.

AlexTekTip

Programmer
Aug 30, 2004
17
US
Hello,

I am trying to extract anything that looks like:

mailto:some_one.me@dom_main.com">


my regex looks something like this:

/mailto:[a-zA-Z0-9_\.]+\@[a-zA-Z0-9_\.]+\"\>/

Given the abobe expression how would I turn off greedy matching? do I just enclose the whole thing in paranthese and end it with a "?
 
Now why would you want to go and do that?
--Paul

at all, at all

It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ... smack the fecker
 
Alex,
This way, you regexep catch sequence of words ended by a point, at each side of "@".

Why dont you :

/mailto:(\w+\.)\w+\@(\w+\.)\w+/

Also, if you can give a sample where gredy and non gerdy can makes a difference will help.

I think what you want to know is the syntax,

\w+ : catch a "word" character one or several tymes greedily
\w+? : catch a "word" character one or several tymes non greedily

HTH,
Zephan

 
Sorry,
There's a mistake in the regeex I provided :
Here's what I wanted :

/mailto:(\w+\.)+\w+\@(\w+\.)+\w+/

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top