Need help in understanding the following examples.
>>> re.search('*.script', 'a.script')
Traceback (most recent call last):
<snipped>
re.error: nothing to repeat at position 0
>>> re.search('\*.script', 'a.script')
>>> re.search('a.script', 'a.script')
<re.Match object; span=(0, 8), match='a.script'>
>>> re.search(r'\*.script', 'a.script')
>>> re.search(r'\\*.script', 'a.script')
<re.Match object; span=(1, 8), match='.script'>
>>> re.search(r'\\\\*.script', 'a.script')
>>> re.search(r'\\\*.script', 'a.script')
>>> re.search('\\*.script', 'a.script')
>>>
When I escape the *, there is no match. When I escape it twice, only .script is matched. How can I use *.script
as regex and match the full string a.script
?