regex: im getting better

Michal Wallace sabren at manifestation.com
Wed Oct 2 20:39:12 EDT 2002


On Wed, 2 Oct 2002, :B nerdy wrote:

> $pattern = '|<input(\s+([^=>]*)="([^"]*)")*>|ism';
> 
> i'd like to match all the input tags's but also in a subexpression, i'd like
> to match each of the parameters in the format
> parameter_name="parameter_value"
> where parameter_name and parameter_value are strings
> 
> my pattern doesnt work, it only matches the last parameter, whats wrong with
> my pattern? and can someone show me how one would match my description
> above?


Why don't you use the various html libraries, or an XML
processing library? (or XQuery for that matter?) (or at the
very least, look in the code to see what they're doing for
this problem)

I don't think you can do what you're doing with one regexp.
I might be wrong, but I think you'd have to match the whole
tag, and then run a second regexp against the match.

Cheers,

- Michal   http://www.sabren.net/   sabren at manifestation.com 
------------------------------------------------------------
Switch to Cornerhost!             http://www.cornerhost.com/
 Low Priced, Reliable Blog Hosting, With a Human Touch. :)
------------------------------------------------------------





More information about the Python-list mailing list