Michael_B
2 years agoOccasional Contributor
Python code to return a substring using regular expressions?
Hello - I'm attempting to return the 5 digits after "ID:" using regular expressions. I have an expression that works (see attachment), but cannot seem to get testcomplete to return it. When I get this script to work with a regular expression, it will help my team with these types of issues without reinventing the wheel with custom wildcard setups and such. Can you see what I am doing wrong? Thanks for your help!
def RegExRSearch():
import re
str = "Smith, Tom\nID:\n69777\nLocation:\nDenver"
# Define regular expression pattern.
regexp = "ID:\n(.{5})"
# Perform replace operation
result = re.search(regexp, str)
Log.Message(result)
- Hi Again,
Yes no as of today.
BR.
We hope you found this email of interest; however, click here if you wish to unsubscribe<> or manage your email preferences. Privacy Policy.<>
Disclaimer
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.