regex - how to truncate a string using regular expression in perl -


I have the following string in a file and do not want to leave the string in more than 6 characters. How to use regular expressions in Perl?
The original file is:

cat shortstring.in:

& lt; Value & gt; 1234@google.com< / Value & gt; & Lt; Value & gt; 1235@google.com< / Value & gt;

I want to get the file as:
cat shortstring.out

& lt; Value & gt; 1234 @ G & lt; / Value & gt;
& lt; Price & gt; 1235 ft. & Lt; / Pricing & gt;

I have a code, as such, s / & lt; Value & gt; There is no more efficient way of using (\ w \ w \ w \ w \ w \ w) (). *) / $ 1 /; ?

Here is a part of my code:

  while (<= input_handle & gt;) {# take an input line at a time; If (/(\d+@google.com) /} {/ ( w / w \ w \ w \ w \ w) (. *) & Lt; / value & gt; / $ 1 /; print output $ $ "$ _ \ n";} Else {print $ output_handle "$ _ \ n";}}  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -