Regex and variable usage
| From: | Gerard Samuel | Date: | Wed, 16 Jul 2003 20:18:07 +0000 |
| Subject: | Regex and variable usage | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-155482@lists.php.net to get a copy of this message | ||
Has anyone had any success with using variables in a regex shown below??
$foo = 3;
$bar = 4;
preg_match('/^[a-z0-9\-_\.]+\.[a-z0-9]{$foo, $bar}$/', $some_string)
or even
preg_match('/^[a-z0-9\-_\.]+\.[a-z0-9]{' . $foo . ', ' . $bar . '}$/', $some_string)
but this would work
preg_match('/^[a-z0-9\-_\.]+\.[a-z0-9]{3,4}$/', $some_string)
Thanks for any pointers..