1

I'm trying to use regex expressions to catch some incoming urls, but I'm having trouble putting the right expression together.

Basically I'm trying to rewrite

mydomain.com/abc12

into

mydomain.com/default.aspx?referrer=abc12

The extension will always be a 5 character [a-z0-9] code, and I can't work out how to match only that specific combination. Anything I write seems to catch all my CSS files and everything as well.

Really I just need to grab that 5 char code, so if you have other suggestions as to how to do that I'm open to other recommendations as well.

stema
  • 90,351
  • 20
  • 107
  • 135
Matthew Rigbye
  • 35
  • 1
  • 1
  • 5

1 Answers1

0

Try to describe the pattern you want to find as good as possible

Maybe something like this:

mydomain\.com/([a-z0-9]{5})$

The quantifier {5} enforces exactly 5 characters and the anchor $ enforces the end of the string after your code.

See it here on Regexr

stema
  • 90,351
  • 20
  • 107
  • 135