Regarding Regular Expression
Posted: Sun Feb 01, 2004 1:12 am
Hello PHP dev,
I have a question regarding regular expression.
suppose I have a strings like 'MR.Dibyendra' , 'DR.Thomas'. If I have to remove the 'MR.' and 'DR.' from the name and want to assign only the name .what should I have to do ?
Here is the code I've tried.But,it assigns NULL to $tmp_name. Dot "." matched all and assigned null . But I want to remove both MR and "." .
How can I match including DOT"." ?
Any help will be appreciated.
Dibyendra
I have a question regarding regular expression.
suppose I have a strings like 'MR.Dibyendra' , 'DR.Thomas'. If I have to remove the 'MR.' and 'DR.' from the name and want to assign only the name .what should I have to do ?
Here is the code I've tried.But,it assigns NULL to $tmp_name. Dot "." matched all and assigned null . But I want to remove both MR and "." .
How can I match including DOT"." ?
Code: Select all
<?php
$tmp_name=strtolower("MR.Dibyendra");
if (eregi("MR.", $tmp_name))
{
$tmp_name = ereg_replace ("MR.", "", $tmp_name);
}
?>Dibyendra