Since Nim shares a lot of features with Python, i would not be surprised if it implements Python's list comprehension too:
string = "Hello 12345 World"
numbers = [x for x in string if x.isdigit()]
# ['1', '2', '3', '4', '5']
Is this actually possible in Nim? If not, could be implemented with templates/macros ?