0

I have strings that are concatenations of airline codes/flightnumbers, separated with ;. The airline code and flight number are either separated by a space or -. So some examples are:

AA-1234;UA 243;EK 23;
9W 23;B6-134

Now I want to grab the airline codes from this.

I came up with the following regex: [a-zA-Z0-9]{2}[ -]. This works to grab the airline codes but also includes the airlinecode-flightnumber separator. How would I adjust my regex to not include this?

Ed Claassens
  • 9
  • 1
  • 3

1 Answers1

1

[a-zA-Z0-9]{2}(?=[ -])

See it in action here

Muldec
  • 4,641
  • 1
  • 25
  • 44