on 08-14-2015 4:51 PM
Hi Experts,
I am looking for split functionality. Is there any keyword to split the string.
Thanks,
Quddus.
hey, I found this piece somewhere but it works.
try to execute below code
import AP.Common.GDT; //for split
var deliveryLocalString = "87676767, 87676766, 87676765, 87676764, 87676763, 87676762";
var deliveryStringTable : collectionof DataType::LANGUAGEINDEPENDENT_EXTENDED_Text; //if it doesn't work try to replace with a string or LongText
// ^ this is the FINAL result of split!
//****************************************************
//first we have a very long string, which we have to split to create a table.
//End of line as delimeter
var split_at = ", "; //your delimiter, cloud be anything e.g. "\n"
var length_at = split_at.Length();
//go through the string and split it
var start = 0;
while (true)
{
// check if start is out of bounds
// find next match
var pos = deliveryLocalString.Find(split_at, start);
// no further occurence found?
if (pos == -1)
{
// check if any characters remain at end of string
if (deliveryLocalString.Length() > start)
{
var remainder = deliveryLocalString.Substring(start);
deliveryStringTable.Add(remainder);
}
// abort loop
break;
}
// otherwise add found string to newlineParsedTab
var sub_length = pos - start;
var substring = deliveryLocalString.Substring(start, sub_length);
deliveryStringTable.Add(substring);
// set new start position for next loop
start = pos + length_at;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.