Regular Expression

Hello all.

I need some help regarding regular expression.

I’m creating a form in which there is field which should be filled by 10 character long alpha-numeric value.

Now I want to check whether that is in correct order or not. But I’m unable to create any regular expression to check that.

In that character the first five character should be alpha, then the next 4 character should be numeric and the last one should be again an alpha.

Please help me.

I’ve tried to make one.

Tell me whether it is right or not.


if(1 === preg_match('~^[a-z]{5}[0-9]{4}[a-z]$~i', $field)){

When I’m trying to validate it by using the code.

I’m getting error. can any body rectify why I’m getting error ?

$pattern = "[A-Z]{5}\\d{4}[A-Z]{1}";
$PAN= "AXYTR2347E";

if(preg_match($pattern, $PAN))
	echo "Successfull.";
	echo "Not able to make";

Error Message is:

Warning: preg_match() [function.preg-match]: Unknown modifier ‘{’ in D:\wamp\www\spa\pantest.php on line 13

Thanx Anthony.

Solved the issue now. :magic::good: