#!/usr/bin/env python3

import re   # regular expressions

txt = "The rain in Spain falls mostly in ..."

xFind = re.findall("in", txt)
print("xFind   : ", xFind) 

xSplit = re.split(" ", txt)
print("xSplit  : ", xSplit) 

# splitting at first position  \s  ==  space
xSplit_1 = re.split("\s", txt, 1)
print("xSplit_1: ", xSplit_1) 

# replace 3 times
xSub = re.sub("\s", "_", txt, 3)
print("xSub    : ", xSub) 

# search for an upper case "S" character in the beginning of a word 
# and print its position:
# span() returns tuple with starting/ending index 
xSpan = re.search(r"\bS\w+", txt)
print("xSpan   : ", xSpan.span())
