简体   繁体   中英

tcl split string with variables

how can split the name in tcl?

NEW in ARCHIVE XVID/J/JURASSIC.WORLD 

path is not always the same, it may also be so

/XVID-BOXSET/007.A.VIEW.TO.A.KILL 

and set this as variable, one variable set the name and one the path.

I need the following variables:

Name example : JURASSIC.WORLD bzw 007.A.VIEW.TO.A.KILL

Path example : XVID/J/ bzw /XVID-BOXSET/

set pn [lindex {NEW in ARCHIVE XVID/J/JURASSIC.WORLD} 3]
# -> XVID/J/JURASSIC.WORLD
set path [file dirname $pn]
# -> XVID/J
set name [file tail $pn]
# -> JURASSIC.WORLD

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