sangeetha
asked on
regular expression
Hi,
Say I have:
<?php
$tmp1 = "string5.php";
$tmp2 = "string51.php";
$tmp3 = "string506.php";
$tmp4 = "string_tmp.php";
?>
I need a regular expression check (preg_match) that returns true for $tmp1, $tmp2 and $tmp3 but returns false for $tmp4. The "string" and ".php" are stable, anything that follows the "string" has to checked whether it is a number of string. If its a number, return true else return false.
I am no good in regular expression. Thank you all.
Say I have:
<?php
$tmp1 = "string5.php";
$tmp2 = "string51.php";
$tmp3 = "string506.php";
$tmp4 = "string_tmp.php";
?>
I need a regular expression check (preg_match) that returns true for $tmp1, $tmp2 and $tmp3 but returns false for $tmp4. The "string" and ".php" are stable, anything that follows the "string" has to checked whether it is a number of string. If its a number, return true else return false.
I am no good in regular expression. Thank you all.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, you're right.
ASKER
Thank you.
You're welcome.
ASKER
There should be definitely, either string or number after the "string". So is this right:
return (preg_match ('/string\d+\.php/ ', $str)>0);
I mean if:
$tmp5 = "string.php";
I want the preg_match to return false.
Thank you.