

Returns the match where a string contains any word characters (characters from a to Z, digits from 0-9, and the underscore _ character) Returns the match where the string DOES NOT contain a white space character Returns the match where the string contains a white space character Returns the match where a string DOES NOT contain digits

Returns the match where the string contains digits (numbers from 0-9) Returns the match where the specified characters are present, but NOT at the beginning (or at the end) of a word Returns the match where the specified characters are at the beginning or the end of a word Returns the match if the specified characters are at the beginning of the string Signals the special sequence (can also be used to escape special characters)Įxactly the specified number of occurrencesĪ particular sequence is a \ followed by one of the characters in the list below and has a special meaning. Metacharacters are characters with a special meaning, which is the following. Let’s replace every white-space character with the symbol ‘~~~’. The sub() function replaces the matches with a text of your choice. Let’s split the string only at the first occurrence. Now, let’s split at each white-space character. The split() function returns the list where the string has been split at each match. Print("The first white-space character is located", pos.start()) If there is more than one match, only the first occurrence of the match will be returned.

The search() function searches the string for the match and returns the Match object if there is a match. If no matches are found, the empty list is returned. The list contains the matches in the order they are found. Python findall() method returns a list containing all matches. It replaces one or many matches with a string Returns the list where a string has been split at each match Returns the Match object if there is a match anywhere in the string Python re module offers the set of functions that allows us to search the string for the match. You can see the return object from the search function.
