I\'m having trouble finding the correct regular expression for the scenario below:
Lets say:
a = \"this is a sample\"
I want to mat
The trouble with regex is that if hte string you want to search for in another string has regex characters it gets complicated. any string with brackets will fail.
This code will find a word
word="is"
srchedStr="this is a sample"
if srchedStr.find(" "+word+" ") >=0 or \
srchedStr.endswith(" "+word):
The first part of the conditional searches for the text with a space on each side and the second part catches the end of string situation. Note that the endwith is boolean whereas the find
returns an integer