I have a Schedule field that stores time values. However, the Schedule field can contain values of different types, such as: "00:00 00:30 01:00 01:30 02:00 02:30 03:00 03:30 04:00 04:30 05:00 2nd Mon". Now, I want to split "00:00 00:30 01:00 01:30 02:00 02:30 03:00 03:30 04:00 04:30 05:00" and display only the specific times, not including "2nd Mon".
Do you have any ideas about how to do this?
Please let me know.
Thank you!
Hi the String_Split action creates a list of entries. If the non-time values are always at the end and if there are always to you could just remove the last two entries from the list (ListRemove). If it can be in between you could still split by a " ", then iterate (for each) over every entry and do a RegEx_Search if the element is a valid time (Regex: ^(?:[01]?[0-9]|2[0-3]):[0-5][0-9]$). If not you remove it from the list.
Best
Stefan
I still don't understand what you mean. Can you explain in more detail?
Hi Phong,
Stefan was being pretty clear, if you do not understand certain parts of his answer, ask specific questions, not "I don't understand".
String_Split is an action from the Text extension, which comes with the Platform so you have it too:
It has, as input, a Text (the text to be split) and a Delimiters parameter, which is also a Text but typically you'll only need a single character (like " " in your case). The output is a List of Text structures (not the Text datatype, slightly confusing), containing the split parts (in your case "00:00", "00:30", ... "2nd", "Mon"). Of course, you don't want "2nd" and "Mon" in there (or any other non-times), so you need to detect and remove them. You can use the various List actions for this (do note that you cannot ListRemove an item of a List you are iterating over with For Each).
Hi @phong vu
For string split use, you can check attach discussion.
https://www.outsystems.com/forums/discussion/50322/how-to-use-string-split/
Thanks
sonali verma
That discussion does not in any way answer this person's problem. Please do not post semi-random links to other posts if they're not the exact solution, thanks.
Hello Phong,
So I got derailed trying to help you so much that I created a forge component based on your question: Regex List Filters.
This component filters a list based on a Regular expression, in your case, you can use this one :
"^([0-1][0-9]|2[0-3]):[0-5][0-9]$"
This will filter your list so that only the times will remain.
I will attach an oml so you can take a look a the String_Split and String_Join actions.
Hope it helps!
Paulo Rosário
I like your answer.
But REGEX can be a bit heavy.In this scenario, if only times can contain the ":" symbol, I would just split the string first, and use ListFilter with the comaparison expression Index(SplittedList, ":") <> -1
That would return a list with the times only.Cheers!
True, but I was thinking about how to apply it in a more broad range of situations. Like I said I got a bit derailed :D
Thanks!
Hello,
Please refer to the below link and let me know if anything else needed -:
Please refer the below post for the solution.
https://www.outsystems.com/forums/discussion/46791/string-split-including-empty-space/
https://www.outsystems.com/forums/discussion/66997/how-to-display-the-string-split-list/
https://www.outsystems.com/forums/discussion/33343/string-split/
Thanks,
Vibhor Agarwal