Hi there Outsystems Community..I've been trying to understand how exactly does the Splint_String works.My objective is to separate a big string that is stored inside a local variable into other variables or a list so I could use later each of the lines.For example:
100000100000000989800800316042100000100000000989800801316045
I want to separate this string for each new line.So I want the "100000100000000989800800316042" in one variable or list line and the "100000100000000989800801316045" in other variable OR a second line of a list.I've found that probably the best way to archieve it was by using a String_Split, because I've noticed that at the end of each line there is an empty character, and I thought I could simply use that space to separate each line.So I was using this:
SyntaxEditor Code Snippet
String_Split(EndResult," ")
"PS: EndResult = Full string of numbers"
My main issue is that I'm not sure in which object should I use the String_Split.
Not sure If I should use it in a table Records, Expression, Lists..I feel a little bit lost with this function.Can somebody give some highlights of what's the best way to separate this string into lines for using them later..Thank you a lot for the help.
Pedro...If you want ALL strings, you have to call it from the Logic. The String_Split returns a LIST, that you can use the way you need it. You can store it in a local list and show it, or process it and put in the result of an aggregate, for example.
Cheers
P.S. If you want to use this list directly as the source of a List Record or Table Record, you can.It will be something like this:
String_Split(your string here).List
That's it.
P.S. 2. Probably it is returning a single line because your separator is wrong...
Eduardo Jauch wrote:
Thank you a lot Jauch, it worked.I've create a ListRecord, where I've placed
String_Split(EndResult,NewLine())
on the ListRecord's Source Record List
and on it's expression I've used
ListRecords1.List.Current.Text.Value
It returned me the string separated by lines as I wanted.
Hello Pedro,
String_Split receives a string, and a separator, and returns a LIST of strings, that represent the strings after the separators are applied.You find a description of it in the Text API.
Splits a string into individual elements delimited by any of the characters in Delimiters.
Inputs
Outputs
So, it returns a list. Usually this means that you need to store or process this list in the LOGIC, rather than in the interface, as in the interface you would not be able to use the full list, but only a single element.
Than you can access the String_Split.List after it.
Hope this helps.Cheers.
P.S. If the string contains "new lines" as separator, you probably wants to pass NewLine() as value for the Delimeters argument. (Didn't tested, could also be possible with "\n"...)
Hello Eduardo,
I want to ask is that mean If i want to check my input whether car license (the first two is letter and 4 digits), I need to use the Text API? Because I want to check each char in string, like I use String[0] == A-Z , String[3]==0-9 in C++? or maybe it will have a easier way to do that?
Thank you.
Mind you, with enter there is a catch of course.
If you have multiple line you can end up with more records in the list than you want, because a newline is actually 2 characters (not always)
so bare in mind that small pitfall.
J. wrote:
Yes. It's a shame this function does not have the option to remove the empty strings... This must be verified after the list is created.
Hi Pedro,
I noticed you try to split your text with " ", i.e. a space. But at the end of a line, there's no space, there's a new line character (or characters). So like Eduardo already said, you need to use the NewLine() Function instead of " ". Note that depending on what kind of new line character(s) you have, this may or may not work. A new line can either be character 10 (Chr(10)) or a combination of character 13 + character 10*. I'm not sure what NewLine() produces.
*I'll ignore the good old Amiga, which had character 13 only.
I want to thank you all the for the answers, but for now I think my main issue is still behind what you guys have suggested me.I've tried to fetch that list with 3 different widgets.1. With an expression which returned me a single line (which makes sense since this widget don't really support lists of content)2. Table Records: I've tried to fetch the information with 2 different expressions
Both of them didn't worked, the first was accepted but returned nothing :PAnd the secondary is not accepted, not really sure exactly what should I write there.3. Tried with a List Record, but end up having the same behavior as the Table Records.
I believe the issue must be something basic stuff on the Outsystems language that I'm missing.What do you guys think?Thank you a lot for the help so far.Cheers
Hi Eva,
For that you can just use the built-in Substr Function:
Alternatively, for checking a certain pattern, you cab use Regex from the Text Extension.