text ="I am \"looking for\" a way that doesn't break: \"Lorem\nipsum\\\" AAAAA\" in this case. Or this AAAAA case. Or this 'AAAAA' case.\nIsn't this annoying?"
print(f"This is the text: {text}")
matches =[f'{x}{y}'for x,y in pattern.findall(text)if'AAAAA'in f'{x}{y}']
This is the text: I am "looking for" a way that doesn't break: "Lorem
ipsum\" AAAAA" in this case. Or this AAAAA case. Or this 'AAAAA' case.
Isn't this annoying?
['"Lorem\nipsum\\" AAAAA"', "'AAAAA'"]