Regular Expressions


Use raw string to escape backslash character in case there is Escape Sequence.

Example: “c:\yaser\now\rule” ‘\n’ and ‘\r’ will be consider as Escape Sequence. when using r”c:\yaser\now\rule” it will be escaped and the python representation will add extra backslash before each backslash. if you want to escape special character in regex don’t forgot to escape them.

Explain

Function

re.search(regex, text)

Example

re.search(r'y', 'yes')

It will return object if there is result otherwise it will be None

Match

References:


  1. 0-9 [return]
comments powered by Disqus