Saori Yoshimoto work notes since 2018

Saturday, October 19, 2019

[VEX] string functions

re_replace()
string  re_replace(string regex, string replacement, string input, int maxreplace=0)
e.g.)
string label = "apple0";
s@name = re_replace("0", "1", label);

split()
string [] split(string s)
string [] split(string s, string separators)
string [] split(string s, string separators, int maxsplits)
e.g.)

s@shop_materialpath = "/obj/matnet1/sardine";
s[]@test = split(s@shop_materialpath,"/");
reslt:[ obj, matnet1, sardine ]
Noted array:
int nums[] = { 0, 1, 2, 3, 4, 5 };
int n = nums[10];  // Returns 0
int b = nums[-2];  // Returns 4

string strs[] = { };
string s = strs[20];  // Returns ""
int nums[] = { 0, 1, 2, 3, 4, 5 };
int start[] = nums[0:2];  // { 0, 1 }
int end[] = nums[-2:];  // { 4, 5 }
int rev[] = nums[::-1];  // { 5, 4, 3, 2, 1, 0 }
int odd[] = nums[1::2]; // { 1, 3, 5 }

No comments:

Post a Comment