^[a-zA-Z]+?x[a-zA-Z]+?x\d+?(\.|,)\d+?-[a-zA-Z]+?:\d+?.+?$
^\D+?x\D+?x\d+?(\.|,)\d+?-\D+?:\d+?x\d+.+?$
import re
ss = [
"HUxRUx23,5-FG:4x45₽",
"HU44xRUx23,5-FG:4x45₽",
"HUxRUx23,5-FG4:4x45₽",
"HUxENx23,5-FG:4x50₽",
]
for s in ss:
if re.match(r"^\D+?x\D+?x\d+?(\.|,)\d+?-\D+?:\d+?x\d+.+?$", s):
#if re.match(r"^[a-zA-Z]+?x[a-zA-Z]+?x\d+?(\.|,)\d+?-[a-zA-Z]+?:\d+?.+?$", s):
print("{} - Ok".format(s))
else:
print("{} - Err".format(s))
HUxRUx23,5-FG:4x45₽ - Ok
HU44xRUx23,5-FG:4x45₽ - Err
HUxRUx23,5-FG4:4x45₽ - Err
HUxENx23,5-FG:4x50₽ - Ok
"<str>x<str>x<float>-<str>:<int>x<int>₽»"
import re
...
def teststr(data: str):
floatre = r"([0-9](?:_?[0-9])*\.(?:[0-9](?:_?[0-9])*)?|\.[0-9](?:_?[0-9])*)"
intre = r"(0[xX](?:_?[0-9a-fA-F])+|0[bB](?:_?[01])+|0[oO](?:_?[0-7])+|(?:0(?:_?0)*|[1-9](?:_?[0-9])*))"
strre = r"([^'\\]*(?:\\.[^'\\]*)*'|[^\"\\]*(?:\\.[^\"\\]*)*\")"
regex = re.compile(r"[a-zA-Z]+x[a-zA-Z]+x"+floatre+r"-[a-zA-Z]+:"+intre+r"x"+intre+r"₽»")
return re.match(regex, data)
...