Gerard Samuel <[EMAIL PROTECTED]> wrote: > 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)
You have single quotes, so php wont expand the variables inside. > > or even > preg_match('/^[a-z0-9\-_\.]+\.[a-z0-9]{' . $foo . ', ' . $bar . '}$/', > $some_string) that should work. but you could do this: $pattern = "/^[a-z0-9\-_\.]+\.[a-z0-9]{$foo, $bar}\$/"; preg_match($pattern, $some_string) > but this would work > preg_match('/^[a-z0-9\-_\.]+\.[a-z0-9]{3,4}$/', $some_string) > > Thanks for any pointers.. Curt -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php