1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

regular expression issue...

Discussion in 'Perl' started by newbie_10, Nov 4, 2011.

  1. newbie_10

    newbie_10 New Member

    Joined:
    Jun 6, 2011
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    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 a moderator: Nov 4, 2011
  2. chorny

    chorny New Member

    Joined:
    Jun 6, 2010
    Messages:
    20
    Likes Received:
    2
    Trophy Points:
    0
    Home Page:
    remove it with regex.
     
  3. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Code:
    if ($nextline =~ /^([a-zA-Z_]*)*]*<\/Register/) 
     

Share This Page