import re
regex = re.compile(r"(?=.*\{myVariable1\})(?=.*<html>)(?!.*<script>)", flags=re.DOTALL)
test_str = ("Recycle Bin <scrippt>\n"
"Assigned to me 18 work items (1 selected)\n"
"ResultsEditorCharts Work item paneBottom\n"
"Save query\n"
"Column options {myVariable1}\n"
"Filter\n"
"IDWork Item TypeTitleStateRemaining WorkSeverityCreated Date705801Bug Ipad Tablet_PM Planning Labor Grid: Show Cost/Billing dropdown menu is overlapped by Plan Settings menu in PM workspace >> Planning Labor gridCommitted 38/24/2016 11:49:02 PM705969Bug Android Tablet_PM Planning Labor Grid: Columns displayed in Labor middle grid are overlappingCommitted 38/25/2016 4:56:55 AM705973Bug Android Tablet_PM Planning Labor Grid: Available Columns and Selected Columns grids are not displayed in Labor Grid SettingsCommitted 38/25/2016 5:08:06 AM712031Bug Column settings do not use the correct defaultsCommitted 39/14/2016 12:22:09 PM716142Bug Ipad Tablet_PM Plan/Project mode: List of Projects are not displayed properly in Project Result list dropdown menuCommitted 39/28/2016 2:06:17 AM707226Task Dev: Client - Remove Project Settings option and move individual settings to other placesDone 8/30/2016 4<html>35:35 PM619943Task Dev: Client - Actions popup menuDone 7/1/2016 2:03:11 PM693953Task dev:fix options above grid (PBI 612771)Done 7/26/2016 1:36:11 PM696198Task Dev: Changes to grid column selection dialog to support cost and billing views.Done 8/1/2016 1:37:43 PM699509Bug # selections above grid doesnt appear when paging is appliedIn Development 38/9/2016 12:46:11 PM699660Bug # selection doesn't show when \"select All\" checkbox is disabledIn Development ")
match = regex.search(test_str)
if match:
print(f"Match 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