Jun-22-2019, 03:33 PM
(Jun-22-2019, 02:22 PM)snippsat Wrote: Your string start with one white-space and end with two,when using^
and$
it most match the begin/end of string exactly on each line.
Could be written like thisnumRegex = re.compile(r"^\s\d{1,3}(,(\d{3})).*$")
Or if strip of white-space it will also work.
import re numRegex=re.compile(r"^\d{1,3}(,(\d{3}))*$") mo = numRegex.search(" 12,124,123,221 ".strip()) print(mo.group())
oh, yeah, i don't know it before. tks verymuch. So it doesn't seem very convenient