As you will find out, there are many ways to do what you ask. I have a regex:
 
#!perl -w
 
_ = 'abcdefghi';

s/(\w{3})(?=\w)/$1-/g;
printf "%-s\n", $_;
Output:
abc-def-ghi
 
The s/ express groups together three characters and then uses (?=\w) to do the hypen if there is a following character if not, then no hyphen(end of data).
 
Wags ;)
-----Original Message-----
From: Michael C. Podlesny [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 13, 2003 19:16
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: HELP!!

Help I have searched everywhere for this
 
 
in Perl I have a value of "ABCDEFGHI"
 
I want to parse this string so that it reads "ABC-DEF-GHI"
 
In other words I want to be able to insert dashes after the third and 6th character.
 
 
Is there anyway to do this in Perl?


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************

Reply via email to