I have list of fake ids in a text file. I wanted to capture all IDs that starts with 'A0015'. I tried different regex but they are not capturing the final output. Which regex should be using?
text = "Here are the fake student ids: IDs A0015-4737, IDs: A0015-384721-ADA2ad, A0015WE382 \n A00152838. Please enter this."
capture_id_list = (re.findall(r"A0015 ([\w-]+)", text,flags=re.IGNORECASE))
print(capture_id_list) # results with []
# print(text.startswith('A0015')) # Gives False...not usefull
find_this = "A0015"
capture_id_list = text[:text.find(find_this) + len(find_this)]
print(capture_id_list) # Here are the fake student ids: IDs A0015. Not the results
Final Output:
['A0015-4737','A0015-384721-ADA2ad','A0015WE382','A00152838']