I'm trying to match only numbers in a string that has text also and I can't for the life of me figure out how the "re" module works with regular expressions. Below is what I have so far. I've been playing around with the regular expressions but just not getting it.
I want to only search for numbers only, not numbers with text. So "12" by itself, not "test12". Just the standalone numbers. Any help is greatly appreciated. Thank you!
I want to only search for numbers only, not numbers with text. So "12" by itself, not "test12". Just the standalone numbers. Any help is greatly appreciated. Thank you!
import re output = "12 test12 13 test13 14 test14 101 test101 102 test102" num_input = int(input("\nEnter number to match: #: ")) num_string = str(num_input) search = re.match(r'\^' + num_string '\$', output) if num_string in search: print("yes") else: print("no")