Regex filter numbers divisible by 3

python, regex

Solution

If you really mean digits (not numbers), this is as easy as

 re.findall(r'[369]', my_str)

For a list of numbers, it's quite easy without regular expressions:

lst = "55,62,12,72,55"
print [x for x in lst.split(',') if int(x) % 3 == 0]

Problem

I have a list of comma-separated ids(digits) . And I need to get only these which are divisible by 3. `Example: i = "3454353, 4354353, 345352, 2343242, 2343242 ..."`

Original source

Related problems