I have the following string in a file and want to truncate the string to no more than 6 char. how to do that using regular expression in perl?
the original file is:
编目短.。 :
<value>1234@google.com</value>
<value>1235@google.com</value>
I want to get file as:
cat shortstring.out
<value>1234@g</value>
<value>1235@g</value>
I have a code as follows, is there any more efficient way than using
s/<value>(wwwwww)(.*)/$1/;
?
这是我守则的一部分:
while (<$input_handle>) { # take one input line at a time
chomp;
if (/(d+@google.com)/) {
s/(<value>wwwwww)(.*)</value>/$1/;
print $output_handle "$_
";
} else {
print $output_handle "$_
";
}
}