Actually, I think you just need to leave off the /g switch if your script is doing that.
 
This should work:
 
$phonenumber = 4062324064;
$phonenumber =~ s/406/302/;  #no /g switch
 
print $phonenumber;
 
An even better idea, though, is to specify that the pattern has to come at the beginning of the word, using the ^, like this:
 
$phonenumber =~ s/^406/302/;
 
 
-----Original Message-----
From: Mike Charles [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 30, 2002 4:52 PM
To: [EMAIL PROTECTED]
Subject: How to search & replace only the first 3 digitsof a 10 digit #? Newbie asks!

What regular expression might I use to replace area codes in a telephone #(or just the first 3 digits of a number. I can't use just a simple search and replace. For example: 4062324064 The new # would change to ex:302233024.
I of course only want the area code or the first 3 digits to be searched.
 
I am brand new to this, yet I a already have a need to replace area codes on a list. Your help is apreciated.
 
Mike Charles

 

--------------------------------------------------------------------------------
This email may contain confidential and privileged
material for the sole use of the intended recipient.
If you are not the intended recipient, please contact
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to