Regexp return true, but author of a book says it shouldn't
php, regex
Solution
Are you sure there isn't supposed to be a trailing `$` there? Without it, returning true makes a lot of sense - the first `[a-z]` block matches the first 2 `a` characters, the `[0-9]` matches nothing, and the last `[a-z]` matches the 3rd `a`. The trailing `1` is ignored.
Looking at the link to the book, it does seem there's an error there:
Must end with a lower case letter
This is only true if the regular expression is anchored to the end of the string with a `$`.
Problem
Reading an online resource on PHP about Regexp(TuxRadar). According to the author the following should not match "aaa1" to the pattern and therefore return false(0), but I get true(1). ``` <?php $str = "aaa1"; print preg_match("/[a-z]+[0-9]?[a-z]{1}/", $str); ?> ``` Why? Regular Expressions