Professional Documents
Culture Documents
File Edit View Insert Cell Kernel Widgets Help Trusted Python 3 (ipykernel)
+ Run Code
In [ ]: #Regular Expressions
In [54]: import re
pattern = '^h.{7}s' # words starting with h and ending with s. its a 9 letter word
test_string = 'happins'
if result:
print("Search successful")
else:
print("Search unsuccessful")
None
Search unsuccessful
In [30]: import re
a = re.search("in", txt)
b = re.findall("in", txt)
c = re.match("Th", txt)
d = re.match("in", txt)
In [32]: import re
['There', 'is', 'no', 'path', 'to', 'happiness;', 'happiness', 'is', 'the', 'path']