regular expression issue...

newbie_10's Avatar
Light Poster
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

Last edited by shabbir; 4Nov2011 at 20:30.. Reason: Code blocks
0
chorny's Avatar, Join Date: Jun 2010
Go4Expert Member
Quote:
Originally Posted by newbie_10 View Post
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.
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Code: Perl
if ($nextline =~ /^([a-zA-Z_]*)*]*<\/Register/)