in reply to regular expressions and match variables

I believe someone told you in your previous thread on this that you need to use "\d" and "\D" in your expressions, not just "d" or "D" (which match literal characters.) As such, your expression isn't matching anything and, consequently, isn't catching anything in $1, $2, and $3. So, when you print $formattedphone all it contains is the literal "+" you have assigned to it.

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re^2: regular expressions and match variables
by sierrastar (Sexton) on Nov 07, 2005 at 01:52 UTC
    HI, I changed the whole thing to this
    $newphone = "+"."1"." ".substr($phone,0,3)." ".substr($phone,3,3)." ". +substr($phone,6,4);
    and just got rid of the match variables....and it worked - thanks so much!