#!/usr/bin/env python3; import Utils import re # Begin Main s = "Four score and seven years ago..." print("Match 1: " + str(Utils.defined(re.compile(r's.*e').search(s)))) print("Match 2: " + str(Utils.defined(re.compile(r'\bs.*e\b').search(s)))) print("Match 3: " + str(Utils.defined(re.compile(r's...e').search(s)))) print("Match 4: " + str(Utils.defined(re.compile(r'b.d').search(s)))) subgroups = Utils.findFirst(re.compile(r'(\w+)\s*(\w+)'), s) print("Find First (with subgroups): " + Utils.listToString(subgroups)) subgroups = Utils.findFirst(re.compile(r'bad match'), s) print("Find First (bad match): " + Utils.listToString(subgroups)) matches = re.compile(r'\w+').findall(s) print("Find All: (matches only)" + Utils.listToString(matches)) matches = re.compile(r'bad match').findall(s) print("Find All (bad match): " + Utils.listToString(matches))