Simplify this regex, remove unnecessary capture group.
This commit is contained in:
parent
9abf74cb9b
commit
f897abce11
1 changed files with 2 additions and 2 deletions
|
@ -103,12 +103,12 @@ def parsebytes(string):
|
||||||
string = string.lower().strip()
|
string = string.lower().strip()
|
||||||
string = string.replace(' ', '').replace(',', '')
|
string = string.replace(' ', '').replace(',', '')
|
||||||
|
|
||||||
matches = re.findall('((\\.|-|\\d)+)', string)
|
matches = re.findall(r'[\d\.-]+', string)
|
||||||
if len(matches) == 0:
|
if len(matches) == 0:
|
||||||
raise ValueError('No numbers found')
|
raise ValueError('No numbers found')
|
||||||
if len(matches) > 1:
|
if len(matches) > 1:
|
||||||
raise ValueError('Too many numbers found')
|
raise ValueError('Too many numbers found')
|
||||||
byte_value = matches[0][0]
|
byte_value = matches[0]
|
||||||
|
|
||||||
if not string.startswith(byte_value):
|
if not string.startswith(byte_value):
|
||||||
raise ValueError('Number is not at start of string')
|
raise ValueError('Number is not at start of string')
|
||||||
|
|
Loading…
Reference in a new issue