For example, using the re module :
1> re:run("1234a56", "^[0-9]*$").
nomatch
2> re:run("123456", "^[0-9]*$").
{match,[{0,6}]}
Or using a list comprehension:
[Char || Char <- String, Char < $0 orelse Char > $9] == [].
Note that both solutions will consider accepting an empty list.
source
share