Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   trouble with regular exp. (http://www.go4expert.com/forums/trouble-regular-exp-t26337/)

newbie_10 21Jul2011 21:47

trouble with regular exp.
 
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 25Jul2011 18:53

Re: trouble with regular exp.
 
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:



ansh batra 3Aug2011 12:39

Re: trouble with regular exp.
 
$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 30Aug2011 13:48

Re: trouble with regular exp.
 
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";



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