Friday, 9 May 2025

splitting strings

I think I did a post on this quite a while ago, though it seemed inconclusive and unsure... This seems to work at the moment.

user gnisbet posted this example on the Sidefx forum:

nicely demo's the vex split function.
 
s@my_string = "/mainfolder/assetFolder/ProjectName_vegetation_big_Tree_eucalyptus_a.abc";

// Grab the value after the last split
s@last_split = split(s@my_string, "/")[-1];

// Grab the last 48 digits
s@last_48 = s@my_string[-48:];

// Define attributes, and then use those in the function to grab those values
string dir, name;
splitpath(s@my_string, dir, name);

// Set the attributes on the points from the values
// You could also define these in the function directly if you'd like
s@dir = dir;
s@name = name;

I can't seem to get it to work if you do:
string test_string=s@my_string;
it seems to require both variables to be "@"'s like
s@test_string=s@my_string;

No comments:

Post a Comment