By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,948 Members | 1,587 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,948 IT Pros & Developers. It's quick & easy.

how to get around greedy * operator?

P: n/a
What regular expression would return only...
id="Table3"

from the string...
height="100%" id="Table3" cellspacing="0" cellpadding="0" width="100%"

I tried...
id=".*"

but I get a match to the end of the line.

I also tried...
id=".*?"

but that didn't find anything.

Thanks for the help,
John
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
John Livermore <jo************@nospm-inginix.com> writes:
What regular expression would return only...
id="Table3"

from the string...
height="100%" id="Table3" cellspacing="0" cellpadding="0" width="100%"
The simplest (generalizable) regular expression would be
/id="[^"]*"/

I also tried...
id=".*?"

but that didn't find anything.


Suprising, depending on what browser you tested in. It should work
in a browser understanding ECMAScript v3 Regular Expressions.
It works for me in Opera 7 and IE 6.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.