import re pattern sys argv[ search_string sys argv[ match re match(patternsearch_stringif matchtemplate "'{}matches pattern '{}'elsetemplate "'{}does not match pattern '{}'print(template format(search_stringpattern)this is just generic version of the earlier example that accepts the pattern and search string from the command line we can see how the start of the pattern must matchbut value is returned as soon as match is found in the following command-line interactionpython regex_generic py "hello worl"hello world'hello worldmatches pattern 'hello worlpython regex_generic py "ello world"hello world'hello worlddoes not match pattern 'ello worldwe'll be using this script throughout the next few sections while the script is always invoked with the command line python regex_generic py """we'll only see the output in the following examplesto conserve space if you need control over whether items happen at the beginning or end of line (or if there are no newlines in the stringat the beginning and end of the string)you can use the and characters to represent the start and end of the string respectively if you want pattern to match an entire stringit' good idea to include both of these'hello worldmatches pattern '^hello world$'hello worldoes not match pattern '^hello world$matching selection of characters let' start with matching an arbitrary character the period characterwhen used in regular expression patterncan match any single character using period in the string means you don' care what the character isjust that there is character there for example'hello worldmatches pattern 'hel world'helpo worldmatches pattern 'hel world