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 more repetitions of the preceding RE, as many repetitions as are possible. ab* will match ‘a’, ‘ab’, or ‘a’ followed by any number of ‘b’s.

e) {m}: Specifies that exactly m copies of the previous RE should be matched; fewer matches cause the entire RE not to match. For example, a{6} will match exactly six 'a' characters, but not five.

f) 

Comments

Popular posts from this blog

What is Navie Bayes Theorem?

Ensemble Methods

Multi-threading in Python