import re
regex = re.compile(r"(\ {|\s+\}|:(?= )|;)")
test_str = (".fixed-feedback-block {\n"
" position: fixed;\n"
" right: 0;\n"
" top: calc(50% - 33px);\n"
" cursor: pointer;\n"
" .inner {\n"
" text-indent: 10px;\n"
" }\n"
" svg {\n"
" width: 50px;\n"
" position: absolute;\n"
" top: 15px;\n"
" left: 0;\n"
" z-index: 85;\n"
" height: 20px;\n"
" }\n"
" .call-me-button {\n"
" width: 240px;\n"
" height: 50px;\n"
" display: block;\n"
" background: #f35556;\n"
" transform: translate3d(190px, 0, 0);\n"
" transition: transform 0.3s ease-out;\n"
" border: none;\n"
" box-shadow: none;\n"
" border-radius: 0;\n"
" &:hover {\n"
" transform: translate3d(0px, 0, 0)\n"
" }\n"
" }\n"
" .write-to-us-button {\n"
" width: 215px;\n"
" height: 50px;\n"
" background: #00a5b8;\n"
" float: right;\n"
" transform: translate3d(165px, 0, 0);\n"
" transition: transform 0.3s ease-out;\n"
" border: none;\n"
" box-shadow: none;\n"
" border-radius: 0;\n"
" &:hover {\n"
" transform: translate3d(0px, 0, 0)\n"
" }\n"
" }\n"
"}")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
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