I wanted to extract the first instance of alphanumeric string and alpha only string. I‘ve provided some examples below for better explanation of what I wish to achieve. Thanks everyone in advance!
E.g
string = “123456 Alphanumeric12 word 7890 Subsequent String”
string2 = “Alphanumeric12 word 7890 Subsequent String”
string3 = “123456 Alphanumeric12 word”
All the examples above should output:
Expected output = “Alphanumeric12 word”
I’ve tried but the closest I got was a list of all alphanumeric and character string which is not what I quite wanted.
Here’s my code:
re.findall(r”(?i)d?(?:[a-z]+[0-9]+|[0-9]+[a-z]+|[a-z]+)d?”,string)