This is possible only if you translate the number to unary ( 1 = 1 , 2 = 11 , 3 = 111 , 4 = 1111 , etc.).
Then you can check if your number matches ^(1{divisor})*$ . If you cannot use {} , you need to specify it. So, to check divisibility by 4, try matching ^(1111)*$ , etc.
No one in their right mind would do it that way. And if your interlocutor asks you to use ereg , then his knowledge of regular expressions a few decades ago, I think.
source share