how to get around greedy * operator?

J

John Livermore

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
 
L

Lasse Reichstein Nielsen

John Livermore said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top