How to pass a empty string in array?

Hi. I have had a lot og progress with my programming thanks to you. Not I am looking for a way in for each to pass an empty string.
In array I can have multiple string wich starts with a date, but how to pass if the strings is missing or does not start with a date= I am only interestet in the strings that contain a date.
Like myArray
string(0) “Empty”
String(1) 04-11-19 bla bla bla
String(2) 04-11-19 bla bla bla
String(3) bla bla bla

Not always in this ordre, may change.
I have used regex to find date: “[0-9]{2}-[a-z]{3,}-[0-9]{2}”
Works fine, also my other regex forks fine, thanks to help from you. Strings starts with date I read fine and result is ok, but prosess stops when it read strings who does not start with date, I am as I said not interested in them.

Regards Kåre

Hi @kare.smorvik
Based on For each item in My Array

Check the condition like String.IsNullOrEmpty(item.ToString) or String.IsNullOrWhiteSpace(item.ToString)

Ashwin S

You can use an inline if statement to set the value to string.empty if the regex does not find a value. This is untested code so you may have to fix some minor issue, but it would be something like this: If(Regex.IsMatch(InputString,"[0-9]{2}-[a-z]{3,}-[0-9]{2}"),Regex.Match(InputString,"[0-9]{2}-[a-z]{3,}-[0-9]{2}").Value,string.Empty)

This first checks if a match is found. If it is found, it gets the string value. If no match is found, it gives a an empty string

1 Like

Works great when I found the correct place to put it, Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.