Remove specific word from strings {[SOLVED]}

   3227   3   0
User Avatar
Member
1177 posts
Joined: April 2017
Offline
Hi!

I have many different s@path on prims. I would like to remove the words "MatSG" from all paths. Is there a function for that?

for example, if I had a string

treeMatSG_topBranchMatSG
should become
tree_topBranch

-Olivier
Edited by olivierth - June 7, 2023 15:27:51
User Avatar
Member
250 posts
Joined: Oct. 2014
Offline
If you're using vex, you should be able to use `replace`


https://www.sidefx.com/docs/houdini/vex/functions/replace.html [www.sidefx.com]


string str = "treeMatSG_topBranchMatSG"
string new_str = replace(str, "MatSG", "")
Edited by Tim Crowson - June 7, 2023 12:08:34
- Tim Crowson
Technical/CG Supervisor
User Avatar
Member
1177 posts
Joined: April 2017
Offline
OMG.... I've used that function so many times and completely forgot about it... Thanks for sending me on the right path!

-Olivier
User Avatar
Member
1853 posts
Joined: May 2006
Offline
The other way is with the attribute string edit sop:

Attachments:
attribute_string_edit.png (52.0 KB)

http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
  • Quick Links