hewarn has asked for the wisdom of the Perl Monks concerning the following question:
I would like to find elegant string matching solution to find all these lines, now I am using something like" VERSION: 0.11 12-Jul-2002 HWe"
Most problems cause those lines that have 4 or 8 spaces before the searched word as in my example. Problem number two is how to remove all but the version number (here 0.11) from that line, I get off all but HWe stays occasionally in the line--> 0.11 HWe. Also sometimes when name is written like Firstname LAstname or /Firstname LAstname after date, only Firstname is removed. My combinations in code are:...... my $vers_1 = "VERSION : "; my $vers1 = "VERSION"; my vers3="#Version"; $vers5="*Version"; . .. if($rivi =~ /^$vers_1/ || $rivi =~ /^$vers1/ || $rivi =~ /^$vers3/ ...... { $rivi=~ tr/:/ /d; # To remove ":" marks $rivi=~ tr/;//d; # To remove ";" marks $teksti = $teksti.$rivi; open (T,">>desc.txt"); print T $teksti; close T; $teksti=""; } ........
Has anyone any ideas? I have gained a lot by reading Perl Monks FAQs during my first 7 months of using Perl BR Hewarn.... $m0=""; $rivi=~ s/\d+-\w+-\d+/$m0/i; # for /Name type of date $rivi=~ s/$cv\w+/$m0/; # NEW trial for /Name type of date $rivi=~ s/\s+\w+\s+\w+/$m0/; $rivi=~ s/\s+\w+\s+\w+/$m0/; .....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching characters
by PodMaster (Abbot) on Aug 05, 2002 at 07:50 UTC |