Match HTML tags in two strings using regex in Python

Posted by jack on Stack Overflow See other posts from Stack Overflow or by jack
Published on 2010-04-20T06:33:57Z Indexed on 2010/04/20 6:43 UTC
Read the original article Hit count: 301

Filed under:
|
|

I want to verify that the HTML tags present in a source string are also present in a target string.

For example:

>> source = '<em>Hello</em><label>What's your name</label>'
>> verify_target(’<em>Hi</em><label>My name is Jim</label>')
True
>> verify_target('<label>My name is Jim</label><em>Hi</em>')
True
>> verify_target('<em>Hi<label>My name is Jim</label></em>')
False

© Stack Overflow or respective owner

Related posts about python

Related posts about html