VEX split, but using a string as separator, not symbol [SOLVED]

   Views 191   Replies 2   Subscribers 0
User Avatar
Member
3 posts
Joined: Dec. 2017
Offline
Hello,

I'm setting up batch processing for a library of assets.
I have a primitive string attribute:
Bridge_Small_Dark_01



I need to procedurally extract the part of the string before "_Dark".

Using split it seems it only accepts singular symbols as a separator (eg "/"), I need to find a way to use the specific string as the separator.



Using "_" as separator and using + etc in split would not work since not all assets have the same number of words before "_Dark"

Also due to the way material library is imported and variants are implemented, I cannot just remove "_Dark" from asset names.



Using

s@name = split(s@name, "_Dark");

does not work. Is there another function I should be looking into?
Edited by juricakrizanic - yesterday 00:32:12
User Avatar
Member
9088 posts
Joined: July 2007
Offline
use re_split() [www.sidefx.com]
string s = "Bridge_Small_Dark_01";
s[]@split = re_split( "_Dark", s );
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
3 posts
Joined: Dec. 2017
Offline
tamte
use re_split() [www.sidefx.com]
string s = "Bridge_Small_Dark_01";
s[]@split = re_split( "_Dark", s );

Thank you Tomas! This is exactly what I was looking for!
  • Quick Links