Can Substitute implement the function of regular substitution?For example, replace the column name [20231216] to show that this 20231216 is a variable 8-digit number:
Col1[20231216]、Col2[20231219]
For( i = 2, i <= N Col( dt ), i++,
ca = Column( i ) << Get Name;
cc = Substitute( ca, "[(.{8,})]", "" );//??
Column( dt, i ) << set name( cc );
);Thanks!
Automation and ScriptingWindowsRe: Can Substitute implement the function of regular substitution?If you want to just remove [] from your string you can provide multiple values for Substitute for example in a list
Names Default To Here(1);
my_str = "[20231216]";
my_new_str = Substitute(my_str, {"[", "]"}, ""); //"20231216"
or you could use regex with something like this
</CODE></PRE>
<P> </P>
<P>Edit:</P>
<P>Regex can also be used to replacements if needed</P>
<PRE><CODE class=" language-jsl">Regex(my_str, "\[\[|\]]\", "", GLOBALREPLACE); // "20231216"Regex(my_str, "\[\[(.*)\]]\", "\1"); // "20231216"
Re: Can Substitute implement the function of regular substitution?Thanks!
Col1[20231216] → Col1
Col2[20231219] → Col2
Re: Can Substitute implement the function of regular substitution?Below are few different options what you could do (if the case is always like those examples, I would most likely use Word)
Names Default To Here(1);
my_str ="Col2[20231219]";
str1 = Word(1, my_str, "[");
str2 = Regex(my_str, "\[^(.+)\[]\", "\1");
str3 = Left(my_str, 4);
str4 = Substr(my_str, 1, Contains(my_str, "[") - 1);
Show(str1, str2, str3, str4);