On the server side:
re.sub(r'^[^\d]*', '', txt)
-
[abc]
matches any character inside, eithera
,b
orc
-
[^abc]
matches any character that is not inside, all buta
,b
orc
-
\d
matches any numerical character -
[^\d]
matches any non numerical character -
[^\d]*
matches a repetition of zero or more non numerical character -
^[^\d]*
matches zero or more non numerical character starting from the beginning of the string (yes, the^
has a meaning if it’s the first character in the pattern, another meaning if it’s the first inside[]
)
On the client side re.sub
does not exist, so you can use re_sub, which behaves slightly differently from the real re.sub
:
re_sub(r'^[^\d]*(.*)', r'\1', txt)