Posts

Showing posts from April, 2020

Regular Expressions in Python

Regular Expressions:  A regular expression (or RE) specifies a set of strings that matches it; the functions in this module let you check if a particular string matches a given regular expression. Regular expressions can contain both special and ordinary characters. Ordinary Characters: Most ordinary characters, like  'A' ,  'a' , or  '0' , are the simplest regular expressions; they simply match themselves. Special Characters: Some characters, like  '|'  or  '(' , are special. Special characters either stand for classes of ordinary characters or affect how the regular expressions around them are interpreted. The special characters are:: a)   ' . '(Dot):   this matches any character except a newline b)   '^':  (Caret.) Matches the start of the string c)  '$':  Matches the end of the string or just before the newline at the end of the string d)   '*':  It causes the resulting RE to match 0 or m