How can I create a regular expression which test if a number is divisible by i (2<=i<=10), 8 expressions in total? One can only assume that integers are positive. You can use symbols [] and [^] , ?, * and + , | and (). PHP’s ereg-function should accept it.
Share
Unless this is a homework problem there is no reason to use regular expressions in this case.
Use the modulus operator, it gives you the remainder of the value divided by.
Edit: Oh it’s an interview question. Yes, the correct answer here is “That is not the correct tool for this problem!”