tags:

views:

40

answers:

2

Hello everyone, I am looking for a reg exp to match 1111111/11 pattern, all numbers are integers.

I will be grateful if anyone can please help? I am not that good in regular expressions.

+1  A: 

Assuming you're trying to match 7 digits, a slash, and then 2 more digits, you'll want a regex pattern like the following:

/^[0-9]{7}\/[0-9]{2}$/

In PHP, your overall code will look something like this:

if (0 !== preg_match('/^[0-9]{7}\\/[0-9]{2}$/', $testString)) {
    // success!
}
Matt Huggins
+1  A: 

if your input string is like abc1234567/89def you could use:

preg_match('~\D\d{7}/\d{2}\D~', $input);
M42