I am new to regex am trying to create a simple regex. I have gotten below so far which works for the format I'm trying to test against.
import re
pattern = '^\+61-' #to ensure that the given string starts with +61
x = re.search(pattern, '+61-457999999')
print(x)
Output:
<re.Match object; span=(0, 4), match='+61-'>
What I'd like to do next is to add the character count check. So I tried to add {}
to the end of my pattern. But this doesn't seem to work. I tried various combinations:
E.g. '^\+61-{1}'
- seems to look for 1 number of occurrence of '+61-'
at the beginning.
What would be an appropriate addition to the regex so:
- The starting characters are always
'+61-4'
- The length of the given input is always 13
This sounds like a simple question but I was unable to find an exact matching answer for Python and the scenario described.