What is difference between '.' , '?' and '*' in Python regular expression?

PythonServer Side ProgrammingProgramming

Special character dot '.'

(Dot.) In the default mode, this matches any character except a newline. If the DOTALL flag has been specified, this matches any character including a newline.

Special character '?'

Causes the resulting RE to match 0 or 1 repetitions of the preceding RE. ab? will match either ‘a’ or ‘ab’

Special character asterisk'*"

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.

Published on 11-Jan-2018 06:47:29