I have a situation where I want to search if a substring exists in a large text. So, I was simply using:
if pattern in text: ...
But, I want to ensure that the existence of "pattern" in "text" is not immediately prefixed or suffixed by alphabets. It's alright if it is lead or trailed by special characters, numbers or whitespaces.
So, if pattern is "abc", match on "some text abc", "random texts, abc, cde" should return True, while search on "some textabc", "random abctexts" should return False (because "abc" is lead or trailed by alphabets).
What is the best way to perform this operation?