Regex pattern to match flight number and aircraft registration ID
Question:
My dataset has Flight number and aircraft reg of the form ‘xx-yyy’ i.e, two alphanumeric characters ‘xx’ followed by a hiphen ‘-‘ followed by 3 to 5 alphanumeric characters and I want to capture them using regex in python.
Examples:
1. pk-bkf
2. id-6236
3. ew-43950
4. 8q-iak
5. q2-274
6. pk-gjr
7. id-12345
I tried using this pattern: ^[a-z0-9]{2}[-][a-z0-9]{3, 5}$
but it doesn’t seem to match them.
Could someone help me write a pattern with this ‘hyphen’ inbetween?
Answers:
My dataset has Flight number and aircraft reg of the form ‘xx-yyy’ i.e, two alphanumeric characters ‘xx’ followed by a hiphen ‘-‘ followed by 3 to 5 alphanumeric characters and I want to capture them using regex in python.
Examples:
1. pk-bkf
2. id-6236
3. ew-43950
4. 8q-iak
5. q2-274
6. pk-gjr
7. id-12345
I tried using this pattern: ^[a-z0-9]{2}[-][a-z0-9]{3, 5}$
but it doesn’t seem to match them.
Could someone help me write a pattern with this ‘hyphen’ inbetween?