#!/usr/bin/env python3
################################################################################### 
# Validate a string with a regex pattern
################################################################################### 
print("Content-Type: text/html \n")     #http header with newline char (required for the web)
print('<pre>')                          #enhance display for the web

import re                               #regular expression module

string = "Hello World"                  #<-- change this string              
regex  = "H.+\s+w.+"                    #<-- change this regex pattern 

print("String: ", string)
print("Pattern:", regex)
print()

if   re.search(regex, string):                                      #case sensitive
        print("String matches regex pattern (case sensitive)")
elif re.search(regex, string, re.I):                                #case insensitive
        print("String matches regex pattern (case insensitive)")
else:
        print("String does not match regex pattern")