PDA

View Full Version : Changing path using Jscript - replace()


SolaGratia77
07-13-2008, 01:45 AM
c:\users\haggai\Softimage\XSI_6.5

I am trying to turn this path into

c:\users\haggai\Softimage

Basically I want to chop off anything after the last \

What would be the best way ?
I have tried to use Jscript replace() method with regular expression
but it's too confusing for me and no success so far....

Any help would be very much appreciated
Thank you

-J

miga
07-13-2008, 04:53 AM
Just use this:

t= "c:\\users\\haggai\\Softimage\\XSI_6.5"
logmessage(t.substr(0,t.lastIndexOf("\\")));

SolaGratia77
07-13-2008, 12:45 PM
Wow, thank you miga! :clap:
That looks awesome !!
I never knew such method existed
Thank you so much for your help !!!
Thank you :)

-J

raul
11-03-2008, 07:00 PM
Is there a way to do the same with Python?