You don't even need re for that, it's a simple string function, no?
string.replace(source, det)


Ron Ganbar
email: [email protected]
tel: +44 (0)7968 007 309 [UK]
     +972 (0)54 255 9765 [Israel]
url: http://ronganbar.wordpress.com/



On 31 May 2012 18:25, mathieu arce <[email protected]> wrote:

>  hello ,
> for get rid of ".nk" you can use re module.
>
> import re
> yourText= "01_sweetTree_v001.nk"
> remove = ".nk"
> rep = ""
> a=re.sub(remove,rep,yourText)
> print a
>
> if you want to replace ".nk" by an other string you just have to enter a
> string in rep.
> Mat.
>
>
>
> ------------------------------
> From: [email protected]
> Date: Thu, 31 May 2012 16:08:47 +0100
>
> To: [email protected]
> Subject: [Nuke-python] Re: Seeing inside a string, to replace a file path
>
> Few more questions on this topic.
>
> I got my path split now into a list using; wPath.split('/')[:2]
> That returns a list; ['C:', 'shotFolder']
> How do I add another item to the list? I try just += a string variable but
> each character is treated as a string in the list giving me; ['C:',
> 'shotFolder', 'r', 'e', 'n', 'd', 'e', 'r']
> There's some kind of concatenation syntax I'm missing.
>
>
> Also, if I have a filename like "01_sweetTree_v001.nk". What's the easiest
> way to get rid of ".nk"? That way I'm left with just the filename,
> "01_sweetTree_v001"?
>
> _______________________________________________ Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to