Hi,
Is there any function that I can use to split text? Ex. TEXT=ABC-123-AABBCC-12AA34BB-BBCCDDEEFF
Considering that I need to separate the text in the example based on the delimiter ˜-˜
Text1=ABC
Text2=123
Text3=AABBCC
Text4=12AA34BB
Text5=BBCCDDEEFF
I know if I use: {Left(TEXT,3)}, I will have = ABC (the text1).
How would be the rest of?
Thank you.
Function - Split Text
-
- Posts: 35
- Joined: Mon Jan 29, 2018 11:04 am
-
- Posts: 7339
- Joined: Tue Mar 20, 2018 5:34 am
Re: Function - Split Text
Hello,
You can use the Substring (string str, int startIndex, int length) function
Retrieves a substring from the specified string. The substring starts at a specified character position and has a specified length.
Thank you.
You can use the Substring (string str, int startIndex, int length) function
Retrieves a substring from the specified string. The substring starts at a specified character position and has a specified length.
Thank you.
-
- Posts: 35
- Joined: Mon Jan 29, 2018 11:04 am
Re: Function - Split Text
Hi Lech Kulikowski,
it could work, however, looking at the example, the length is dynamic, and we have the delimiter that is dash, so, besides the substring, I will need also to find the next dash and subtract to the last length in order to get the new length.
des anyone have any idea or some hints?
thank you.
it could work, however, looking at the example, the length is dynamic, and we have the delimiter that is dash, so, besides the substring, I will need also to find the next dash and subtract to the last length in order to get the new length.
des anyone have any idea or some hints?
thank you.
-
- Posts: 7339
- Joined: Tue Mar 20, 2018 5:34 am
Re: Function - Split Text
Hello,
You can add your own function to spit text in the dictionary:
You can add your own function to spit text in the dictionary:
Code: Select all
public class MyFunction
{
private const string Category = "MyFuncCategory";
public static string MyFunc(string value)
{
return value.ToUpper();
}
public static void RegisterFunctions()
{
var ParamNames = new string[1];
var ParamTypes = new Type[1];
var ParamDescriptions = new string[1];
ParamNames[0] = "value";
ParamDescriptions[0] = "Descriptions";
ParamTypes[0] = typeof(string);
Stimulsoft.Report.Dictionary.StiFunctions.AddFunction(Category, "MyFunc", "MyFunc", "Description", typeof(MyFunction),
typeof(string), "Return Description", ParamTypes, ParamNames, ParamDescriptions);
}
}