1
Answer

Regex help

Ask a question
David Smith

David Smith

11y
1.1k
1
I am trying to create another array from the input history array of strings. The new array will have just the On/Off values below. Below my regex will not work because the input history array has datetime stamp included. I trying to either ignore the timestamp or remove the timestamp if that makes sense


history[0]= "1:05:00 PM 06/25/2013 On"
history[1]= "1:10:00 PM 06/25/2013 Off"
history[2]= "1:15:00 PM 06/25/2013 On"
history[3]= "1:20:00 PM 06/25/2013 Off"
history[4]= "1:25:00 PM 06/25/2013 On"
history[5]= "1:30:00 PM 06/25/2013 Off"

   static bool ValidateOnOffHistoryFormatSequence(string[] history)
      {
           ///////NewHistory = history

          return Regex.IsMatch(String.Join("", NewHistory ), "^(OnOff)+$");
      }


Answers (1)
Next Recommended Forum