VEX String, remove ".obj" from path

   1060   3   1
User Avatar
Member
1004 posts
Joined: April 2017
Offline
Hi!

I have a path ending with ".obj". What function could remove it?

-Olivier
User Avatar
Member
1004 posts
Joined: April 2017
Offline
I ended up using the split function. It works but I'm afraid I might run into problems with paths that contain more that one "." Like "...geo.0001.obj"
Edited by olivierth - Oct. 20, 2021 17:20:15
User Avatar
Member
8538 posts
Joined: July 2007
Offline
olivierth
I ended up using the split function. It works but I'm afraid I might run into problems with paths that contain more that one "." Like "...geo.0001.obj"
just join all but last together
string path = "/some/path/file.name.ext";
string path_noext = join(split(path, ".")[:-1], "."); 

that being said you may still run into issues for extensions that have . in there
like .bgeo.sc, even though you can use .bgeosc yourself but just in general
anyway there will always be edge cases you may want to account for or not
Edited by tamte - Oct. 20, 2021 17:25:53
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
169 posts
Joined: Nov. 2013
Offline
Tamte answers this another way in an older thread: www.sidefx.com/forum/topic/57128/

string path = "../my/path/to/geo.0001.obj";
s@path = re_replace(".obj", "", path);
  • Quick Links