Cannot give limits to preg_match
<p>I just want to make a function to check a string and I want to tell minimum and maximum number  of characters. </p>

<pre><code>function check_strict_name($str, $fieldname, $min, $max) {
    $field_errors = array();
    if (preg_match('%^[A-Za-z\.\'\-]{$min, $max}$%', stripslashes(trim($str)))) {
    } else {
        $field_errors[] = $fieldname;
        $field_errors[] = "Info not accepted"; 
    }    
    return $field_errors;   
}
</code></pre>

<p>If I replace <code>{$min, $max}</code> with <code>{2, 25}</code> it works fine but I want to be able to tell these numbers when I call the function. I think I understand why it is not working, because the $-sign ends the expression, but I don't know how to replace the <code>{$min, $max}</code> with something that does work. </p>
