|
Another way to handle this would be using substr:
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 ;)
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. ****************************************************************
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
|