Simple regular expression example fails

I read this example in my lessons:

<?php
    $preg = '[a-z]{4}[0-9]{5}';
    $string = 'abcd12345efg';
    preg_match($preg, $string, $arr);
    print_r($arr);
?>

As I understand, the pattern ‘[az]{4}[0-9]{5}’ is equal to the pattern: ‘[az][az][az][az][0-9][0-9] [0-9][0-9][0-9]’
How not twisted, as a result I get:

Warning: preg_match() [function.preg-match]: Unknown modifier ‘{‘ in C:wwwreg.php on line 6

And this error occurs if there is a second pair of curly or square brackets.
Tell me what I’m doing wrong here?


Answer 1, authority 100%

$preg = '/[a-z]{4}[0-9]{5}/';

Answer 2, authority 75%

Don’t forget to include the beginning and end of the line as well

$preg = '/^[a-z]{4}[0-9]{5}$/';

otherwise your expressions may work incorrectly
In the first case

343dfsa32134 //true

and in the second

343dfsa32134 //false

you can sometimes suffer for a very long time to understand why the regular season does not work quite correctly


Answer 3, authority 25%

you can also $preg = ‘/^([a-z0-9]{5,})$/’;