简体   繁体   中英

How I can remove extension from string in list (groovy)?

I have list def list = ['values.txt'] and I want to remove extension from filename and receive string . How I can do this ?

Expecting result is -- filename = 'values' .

If you happen to open ANY Groovy book or tutorial you would find a lot of solutions.

For example:

def list = ['values.txt']
def noExtensions = list.collect{ it.split( /\./ )[ 0 ] }
assert ['values'] == noExtensions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM