You realize your both absolutely no help, right!
I have been spiting and parsing string going on 30 years, I know most of the tools available.
I don't know how to apply them in this case.
I need details, and not just split at the space or find the index of the space and trim to the right.
I need the examples, docs don't have the needed examples, it only has the tool.
Actually, what I really want it the exact sting parsing algorithm.
The original_string string actually looks like these examples.
xxxxx1 xxxxxxxx xxxx
xxxxx2 xxxx-xxxx 23xxxx
....
xxxxx12 xxxx-23-xxxx 23456
...
xxxxx121 xxxxxxxx
What I already have is...
- Code: Select all
var parsed_string = string.trim(original_string, -1, string.isalpha);
Gives me the problem I propose
1 xxxxxxxx xxxx
2 xxxx-xxxx 23xxxx
....
12 xxxx-23-xxxx 23456
...
121 xxxxxxxx
var parsed_string = string.trim(original_string, 1, string.isalpha);
I guess doesn't work because it hits the space?
Neither of these work either
var parsed_string = string.trim(original_string, -1, string.isspace);
var parsed_string = string.trim(original_string, -1, string.isblank);
I tried looping through the string to get the index of the first space, using for loop and forindex loop.
But I think syntax is wrong using for loop or forindex can't be used this way.
- Code: Select all
var ndx = -1;
for (i=0; i<utf8.size(parsed_string); i++) {
if (utf8.strc(parsed_string, nx) == ' ') {
ndx=nx;
break;
}
}
forindex (var nx; utf8.size(parsed_string)) {
if (utf8.strc(parsed_string, nx) == ' ') {
ndx=nx;
break;
}
}
Then next would be.
- Code: Select all
var final_string = utf8.substr(parsed_string, 0, ndx);
There should be a way to find the first space using substring alone, but I can't find it.
IE:
- Code: Select all
var final_string = utf8.substr(parsed_string, 0, index_of_first_space);