Robert said:
Arowana said:
I used regular expression to grep content from a web page,but it seems
ruby always match the longest string,but I need to fetch the shortly
matching. How can I do ?
Thanks for help!
Would be nice to see the regexp. Maybe using non-greedy multipliers will
do.
You could also use character classes like [^<>] to match chars between <
and >.
But I don't know what you want to match, so please show me :>
Thanks Robert!
here is the example.
<tr><td>Format</td></tr><tr><td>Format2</td></tr><tr><td>Format3</td></tr>
I use the code below to fetch "Format" and "Format2" in the table
feature=content.scan(/[<tr><td>([\w\s])*<\/td><\/tr>/)
I want to get each row into array feature,like
feature[0]=Format;feature[1]=Format2...
but it match all the row into
feature[0]=Format</td></tr><tr><td>Format2</td></tr><tr><td>Format3