Search code examples
phpurl-rewritingurl-routingdigitsletter

How to determine if a URL starts with numbers ends in a letter


I need to found a way to find out if the URL being requested is starting with 5 digits and ends with a letter

13373W

I know if I do this

(\d+)

it matches the numbers (digits) however once I had the W on the end of the string that no longer works.

I am wondering what is the correct way to do this - now as we get bigger and more people join, we will move to 6 numbers and so on, but the letter should always be at the end.


Solution

  • The regular expression should be:

    /\d+[A-Z]$