What is Regular Expression?

Regular Expression. Source: hamradio.my

Regular Expression. Source: hamradio.my

Regular Expression (RegEx) is an order of special character that use search pattern to find string or group of strings.

Example

import re
s = 'MySkill: portal for any learning path'

match = re.search(r'portal', s)

print('Start Index:', match.start())
print('End Index:', match.end())
Start Index: 9
End Index: 15

The above code gave early index and last index from string portal.

Note: Here r character (r'portal') means raw, not regex. Raw string is little different from ordinary string, it will not interpret character\ as runaway character. This because the expression of the machine use character \ as the purpose to runway itself.