|
Posted by Karel de Vos on 12/17/54 11:52
crescent_au@yahoo.com wrote:
>> It most likely has to do with the greediness of *. Regular expressions
>> will match the *longest* possible string. To prevent this, use '?'.
>> given the string: "<a>text</a>more</a>"
>> <a>.*</a> matches "<a>text</a>more</a>"
>> <a>.*?</a> matches "<a>text</a>"
>
> Well what i basically want is:
> <a class="something" href=http://something.com/abc.php">Shopping
> Cart</a>
>
> I want the RE to parse the HTML tag and see if it starts with '<a
> class="something" href=', then IGNORE whatever is between 'href=' and
> '>', and ending with '</a>'. I couldn't figure out how to "ignore" the
> text in between.
>
Instead of a (greedy) * operator, use a negation class that parses
everything upto an certain character :
/(<a\ class\=link\ href\=([^>]*)>)([^<]*)(<\/a>)/
Navigation:
[Reply to this message]
|