[Solved] How to extract an alphanumeric string from a sentence if a starting point and end point is given [closed]
[ad_1] Using regex Code import re def extract(text): ”’ extract substring ”’ pattern = r’^G.*[794]’ # pattern ends in 7, 9, 4 # Find pattern in text m = re.match(pattern, text) # find pattern in string if m: # Found pattern substring # Remove space, \, (, – by replacing with empty string m = … Read more