

The dollar symbol $ is used to check if a string ends with a certain character. No match (starts with a but not followed by b) The caret symbol ^ is used to check if a string starts with a certain character.

Before we explore that, let's learn about regular expressions themselves. There are other several functions defined in the re module to work with RegEx. The method returns a match object if the search is successful. Here, we used re.match() function to search pattern within the test_string.

Python has a module named re to work with RegEx. The pattern is: any five letter string starting with a and ending with s.Ī pattern defined using RegEx can be used to match against a string. A Regular Expression (RegEx) is a sequence of characters that defines a search pattern.
