• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fetch the last value from the file which contains single line

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Team,

I have the below data in one file:

-rw-rw-rw-   1 user     group        7512 Jul  6 16:39 DataWarehouse37_FE_USA_M_20160706_delete.txt

I would like to get the last value like: DataWarehouse37_FE_USA_M_20160706_delete.txt
from the above line through regexp.

I tried using with ([^_]*[^.]*)$ but the output I am getting is only     delete.txt
but I want to retrieve the last word like : DataWarehouse37_FE_USA_M_20160706_delete.txt

Please help me to get the last word/value from the line.

Thanks in adavance
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think about how you would describe this without a regular expression? Is it all the characters after the last whitespace? Is it the 7th column? Is it the 7th column to the end?
 
Ranch Hand
Posts: 376
2
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I agree that column parsing (awk) would be better.

Anyway, this is a simple RE:



 
Krish Yeruva
Ranch Hand
Posts: 60
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Morris and Boyarsky,

Thanks for your response,

I have used the below regexp to get the last word/value from the single line file in AntScript:

<propertyregex property="FTPFileName" input="@{line}" regexp="([^\s]*)$" select="\1" />

And it is working fine.

Thanks for your support.


 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great! Thanks for sharing it!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic