(Mar-18-2019, 03:18 PM)gentoobob Wrote: 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!The need to Lookahead and Lookbehind as it called in regex,to make sure that numbers are alone and not in string.
>>> import re >>> >>> output = "12 test12 13 test13 14 test14 101 test101 102 test102" >>> r = re.findall(r"(?<!\S)\d+(?!\S)", output) >>> r ['12', '13', '14', '101', '102']