I'm getting an error message when I run my code... (Python 3.5.1)
sre_constants.error: nothing to repeat at position 0
I can't find mistakes in my code, I think the error isn't even in my code.
This is my code:
import re
numberRegexa = re.compile(r'06\d{8}')
numberRegexb = re.compile(r'06 \d{8}')
numberRegexc = re.compile(r'31 6 \d{8}')
numberRegexd = re.compile(r'+31 6 \d{8}')
numberRegexe = re.compile(r'316\d{8}')
numberRegexf = re.compile(r'+316\d{8}')
numberRegexg = re.compile(r'316 \d{8}')
numberRegexh = re.compile(r'+316 \d{8}')
numberRegexi = re.compile(r'31 6\d{8}')
numberRegexj = re.compile(r'+31 6\d{8}')
##numberRegexAll = [
## (1, numberRegex06a),
## (2, numberRegex06b),
## (3, numberRegex31a),
## (4, numberRegex31b),
## (5, numberRegex31c),
## (6, numberRegex31d),
## (7, numberRegex31e),
## (8, numberRegex31f),
## (9, numberRegex31g),
## (10, numberRegex31h),
##]
def searchNumber():
result = numberRegex06a.search(userInput)
print('Found: ' + result.group())
userInput = input("Insert text you'd like searched:\n")
searchNumber()
And this is my log:
Traceback (most recent call last): File "C:/Users/Hibuna/Desktop/asdsad.py", line 6, in numberRegexd = re.compile(r'+31 6 \d{8}')
File "C:\Programs\Python 3.5.1\lib\re.py", line 224, in compile return _compile(pattern, flags)
File "C:\Programs\Python 3.5.1\lib\re.py", line 293, in _compile p = sre_compile.compile(pattern, flags)
File "C:\Programs\Python 3.5.1\lib\sre_compile.py", line 536, in compile p = sre_parse.parse(p, flags)
File "C:\Programs\Python 3.5.1\lib\sre_parse.py", line 829, in parse p = _parse_sub(source, pattern, 0)
File "C:\Programs\Python 3.5.1\lib\sre_parse.py", line 437, in _parse_sub itemsappend(_parse(source, state))
File "C:\Programs\Python 3.5.1\lib\sre_parse.py", line 638, in _parse source.tell() - here + len(this))
What the hell is going on? I really don't understand this advanced stuff, I'm pretty new to programming..
Thanks in advance!
+sign is special; you'll want to escape it. - user707650