Last active
May 5, 2019 16:11
-
-
Save sebagomez/c7f10fdb66a71865da152686b82ade57 to your computer and use it in GitHub Desktop.
Flight number parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static (string airline, string number) Parse(string flightNumber) | |
{ | |
string airline = "", number = ""; | |
flightNumber = flightNumber.Trim().Replace(" ", ""); | |
for (int i = 0; i < flightNumber.Length; i++) | |
{ | |
char c = flightNumber[i]; | |
if (c > 64 && string.IsNullOrEmpty(number)) | |
airline += c; | |
else | |
{ | |
if (i <= 1) | |
airline += c; | |
else | |
number += c; | |
} | |
} | |
return (airline, number); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment