trouble with regular exp.

newbie_10's Avatar
Light Poster
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?
vikky1988i's Avatar, Join Date: Apr 2010
Go4Expert Member
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.


newbie_10 like this
ansh batra's Avatar, Join Date: Jan 2010
Light Poster
$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
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Code: Perl
my $a = 'F0_FN_C_B 0800 4:0 s_x_f_c 0800 gg 09 F_C_BL';
$a =~ /(\S+)$/;
print "$1\n";