1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

trouble with regular exp.

Discussion in 'Perl' started by newbie_10, Jul 21, 2011.

  1. newbie_10

    newbie_10 New Member

    Joined:
    Jun 6, 2011
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    define F0_FN_C_B 0800 4:0 s_x_f_c 0800 gg 09 F_C_BL

    this is a line from a file and I want to extract the last column in the line which is in this case 'F_C_BL'

    how do I do that?
     
  2. vikky1988i

    vikky1988i New Member

    Joined:
    Apr 1, 2010
    Messages:
    25
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Mainframes Admin. @ I | Nautix Technologies
    Location:
    chennai , Tamil Nadu ,INDIA
    The Line which u have mentioned :
    define F0_FN_C_B 0800 4:0 s_x_f_c 0800 gg 09 F_C_BL

    Considering/ Assuming before the sub-string (F_C_BL) , there will be a 2 digit number followed by a space , i write this regular expression.

    [\w\W\s*]\d\d\s([A-Za-z0-9]+)\s*\-([A-Za-z0-9]+)\s*\-([A-Za-z0-9]+)\s*

    I think the above regex will work fine....Thank you.:pleased:


     
    newbie_10 likes this.
  3. ansh batra

    ansh batra New Member

    Joined:
    Jan 17, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    $a='F0_FN_C_B 0800 4:0 s_x_f_c 0800 gg 09 F_C_BL';
    $a=~/.*\d\d /;
    print "$'\n";
    same asumptions
     
  4. 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:
    my $a = 'F0_FN_C_B 0800 4:0 s_x_f_c 0800 gg 09 F_C_BL';
    $a =~ /(\S+)$/;
    print "$1\n";
     

Share This Page