# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"(>.*?)\QStyle\E([^=][^<]*)"
test_str = "<div><p style=\"text-align:left;\">Style: <span style=\"float:right;\">Casual</span></p></div><div><p style=\"text-align:left;\">Color: <span style=\"float:right;\">Navy Blue</span></p></div><div><p style=\"text-align:left;\">Pattern Type: <span style=\"float:right;\">Plain</span></p></div><div><p style=\"text-align:left;\">Neckline: <span style=\"float:right;\">Round Neck</span></p></div><div><p style=\"text-align:left;\">Length: <span style=\"float:right;\">Long</span></p></div><div><p style=\"text-align:left;\">Type: <span style=\"float:right;\">A Line</span></p></div><div><p style=\"text-align:left;\">Details: <span style=\"float:right;\">Pearls</span></p></div><div><p style=\"text-align:left;\">Details: <span style=\"float:right;\">Frill</span></p></div><div><p style=\"text-align:left;\">Details: <span style=\"float:right;\">Beaded</span></p></div><div><p style=\"text-align:left;\">Details: <span style=\"float:right;\">Pocket</span></p></div><div><p style=\"text-align:left;\">Sleeve Length: <span style=\"float:right;\">Half Sleeve</span></p></div><div><p style=\"text-align:left;\">Season: <span style=\"float:right;\">Spring/Fall</span></p></div><div><p style=\"text-align:left;\">Composition: <span style=\"float:right;\">75% Cotton</span></p></div><div><p style=\"text-align:left;\">Composition: <span style=\"float:right;\">Denim</span></p></div><div><p style=\"text-align:left;\">Composition: <span style=\"float:right;\">25% Polyester</span></p></div><div><p style=\"text-align:left;\">Fabric: <span style=\"float:right;\">Non-Stretch</span></p></div><div><p style=\"text-align:left;\">Waist Line: <span style=\"float:right;\">Natural</span></p></div><br /><table border=\"1\"><thead><tr><th>size</th><th>Shoulder </th><th>Bust </th><th>Waist Size </th><th>Hip Size </th><th>Sleeve Length </th><th>Length </th><th>Bicep Length </th><th>Cuff </th></tr></thead><tbody><tr><td>XS</td><td> 38 cm</td><td> 91 cm</td><td> 90 cm</td><td> 101 cm</td><td> 39 cm</td><td> 139 cm</td><td> 30 cm</td><td> 25 cm</td></tr><tr><td>S</td><td> 39 cm</td><td> 95 cm</td><td> 94 cm</td><td> 105 cm</td><td> 40 cm</td><td> 140 cm</td><td> 31 cm</td><td> 26 cm</td></tr><tr><td>M</td><td> 40 cm</td><td> 99 cm</td><td> 98 cm</td><td> 109 cm</td><td> 41 cm</td><td> 141 cm</td><td> 32 cm</td><td> 27 cm</td></tr><tr><td>L</td><td> 41 cm</td><td> 103 cm</td><td> 102 cm</td><td> 113 cm</td><td> 42 cm</td><td> 142 cm</td><td> 33 cm</td><td> 28 cm</td></tr></tbody></table>"
subst = "$1MODIFIED_COLOR$2"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html