Hey.. how can i trim, split, etc a string?
I have a gile that contains something similar to this: {text=Clear}
I want to remove the "{text=" as well as the end "}". I have tried:
-filename = "test.mp3";
name = left(filename, length(filename) - 4);
And tried with right command.
I have also tried putting the text in an object and using remove.
Ultimately i have no idea how to do it
Remove part of string??
Moderator: Martin
Re: Remove part of string??
Use replace().
However, once your data started to become more and more complex, using replace will be so painfully long.
Better method is to use regex.
{} are special char in regex, so have to be escaped with backslash. The backslash itself is also special char again Automagic scripting, have to escaped again, ends up double backslash to escape the curly braces.
(.*) to capture any text in between.
[0][1] to access the capture group 0 (first whole capture) and then the subgroup 1.
Code: Select all
text = '{text=Clear}';
rep = replace(replace(text, '{text=', ""), '}', "");
Better method is to use regex.
Code: Select all
text = '{text=Clear}';
regex = findAll(text, '\\{text=(.*)\\}', true)[0][1];
(.*) to capture any text in between.
[0][1] to access the capture group 0 (first whole capture) and then the subgroup 1.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Remove part of string??
Oh fantastic as usual darling... thankyou.