Extract last word on line 
Author Message
 Extract last word on line

Need Perl syntax to extract last word of a line.

ex. "this is a test".

extracts "test".



Mon, 05 Sep 2005 13:56:15 GMT  
 Extract last word on line

Quote:

> Need Perl syntax to extract last word of a line.

> ex. "this is a test".

> extracts "test".

print ((split /\s/, "this is a test")[-1]);

jue



Mon, 05 Sep 2005 14:57:41 GMT  
 Extract last word on line
$string= /(\w+)$/;
print $1;

bd, gerry



Quote:
> Need Perl syntax to extract last word of a line.

> ex. "this is a test".

> extracts "test".



Mon, 05 Sep 2005 19:01:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Extracting last few characters in a line

2. extracting word from line

3. Extract the nth word from a line

4. How to: Create Regex which extracts N number of words before target word

5. read last line without reading previous lines, how?

6. problem about extract line by line from file

7. Extracting last element from a list

8. Extracting "File last accessed" date

9. Last Logon info extracted from RAS server logfiles Help

10. Extract first&last date

11. Using substition to remove the last occurance of a word

12. Q: sort on last word in field/record

 

 
Powered by phpBB® Forum Software