Quantcast
Viewing all articles
Browse latest Browse all 14069

how find the same xml element repeatedly in a string through regex

I want to find the multiple Same xml element repeatedly present in a string trough regex (but it contain different value in the xml element).I tried but unable to find the correct coding in python. how to write the correct pattern in regex.

MWE:

import rexml_data = """<fp>xxxx</fp><fp>xxxxy</fp><fp>xxxx</fp><fp>yyyy</fp>"""pattern = re.compile(r'(<fp>(((?!</fp>).)*)</fp>)\s*\1')matches = pattern.findall(xml_data)for match in matches:    print("Match:", match)

Viewing all articles
Browse latest Browse all 14069

Trending Articles