I want to extract the no. 12 in this text. how can we achieve that? Here's the text.
text = "Car Window Clip-on - Buy Here Pay Here (Blue) - Pack of 12"
the text is not fix but the pack of N
is fix
I want to extract the no. 12 in this text. how can we achieve that? Here's the text.
text = "Car Window Clip-on - Buy Here Pay Here (Blue) - Pack of 12"
the text is not fix but the pack of N
is fix
You can use a regex search!
import re
text = "Car Window Clip-on - Buy Here Pay Here (Blue) - Pack of 12"
match = re.search(r"Pack of (\d+)", text)
if match:
print(match.group(1))
You can use regex with lookbehind
import re
res = re.search('(?<=Pack of )\d+', text)
if res:
print(res.group())