Link to home
Start Free TrialLog in
Avatar of sangeetha
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.
ASKER CERTIFIED SOLUTION
Avatar of T22
T22

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sangeetha
sangeetha

ASKER

Thanks, I assume \d*\ means 0 or more digits. Is it right?

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.
Yes, you're right.
Thank you.
You're welcome.