• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Fetch the last value from the file which contains single line

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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: 40212
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • 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: 357
2
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • 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
  • 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: 40212
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! Thanks for sharing it!
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic