Skip to content

Instantly share code, notes, and snippets.

@sebagomez
Last active May 5, 2019 16:11
Show Gist options
  • Save sebagomez/c7f10fdb66a71865da152686b82ade57 to your computer and use it in GitHub Desktop.
Save sebagomez/c7f10fdb66a71865da152686b82ade57 to your computer and use it in GitHub Desktop.
Flight number parser
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