Regex format check

I need help with the some regex. I want to create regex to format check the following

[Airline - 2 letters][Flight Number- between 3 and 4 numbers][Time 24H 00:00][City Code - 3 letters][DDMM]

Example AA 1234 12:30 CUN 01JUN

Thanks in advance

Hi,

Can you try the following?

System.Text.RegularExpressions.Regex.IsMatch(yourString.Trim,"^[A-Z]{2} \d{4} [0-2]\d:[0-5]\d [A-Z]{3} \d{2}(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)$")

Regards,

Thanks Heaps you are legend

Hi Yoichi

There will be scenario that one cell will have two notes

image

How that’s going to work because as soon I add a space regex match is gone

image

Hi,

How about the following pattern?

^(\s*[A-Z]{2} \d{4} [0-2]\d:[0-5]\d [A-Z]{3} \d{2}(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\s*)+$

Regards,

1 Like

Yes it worked. Thanks heaps


  1. A-Z ↩︎

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