Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   regular expression issue... (http://www.go4expert.com/forums/regular-expression-issue-t27091/)

newbie_10 4Nov2011 19:33

regular expression issue...
 
I have a script that would check a xml file and find me strings that are between tags <Register> ...</Register>

script is :
Code:

while (my $line = <FILE>)
{
if ($line =~ m/<Register>/)   
{
my $nextline =<FILE>;   

if ($nextline =~ /^(.*)]*<\/Register/)
{

my $string = $1;


push(@register_list, $string);


}

else
{
print "You have a problem \n";   

}
}
}

which is giving me the following

SG_u_EO_RX_FI_RD_WR_PT_OET[4:0]
GG_RR_AA_FFER_ASD_u_aSD_DAS_B[99999999]
GG_RR_AA_u_aSD_DAS_C[25:0]

what can i do so i get only this

SG_u_EO_RX_FI_RD_WR_PT_OET
GG_RR_AA_FFER_ASD_u_aSD_DAS_B
GG_RR_AA_u_aSD_DAS_C

chorny 11Nov2011 05:48

Re: regular expression issue...
 
Quote:

Originally Posted by newbie_10 (Post 88856)
which is giving me the following

SG_u_EO_RX_FI_RD_WR_PT_OET[4:0]
GG_RR_AA_FFER_ASD_u_aSD_DAS_B[99999999]
GG_RR_AA_u_aSD_DAS_C[25:0]

what can i do so i get only this

SG_u_EO_RX_FI_RD_WR_PT_OET
GG_RR_AA_FFER_ASD_u_aSD_DAS_B
GG_RR_AA_u_aSD_DAS_C

remove it with regex.

pradeep 25Nov2011 11:08

Re: regular expression issue...
 
Code: Perl

if ($nextline =~ /^([a-zA-Z_]*)*]*<\/Register/)



All times are GMT +5.5. The time now is 15:15.