I have a url that contains a ~, and I need to handle the encoded version of this character %7E.
Currently, we have 2 rules to handle this case.
^/folder/([\w-]+)~(\d*).aspx$
^/folder/([\w-]+)%7E(\d*).aspx$
Can I combine this into one rule? I tried the following but it does not work:
^/folder/([\w-]+)[~|%7E](\d*).aspx$
Any help with this rule is appreciated.
Maybe you would like to try
or
to keep your capture groups the same if you regex engine supports this syntax.
This
[…]constructs a character class, not a group of alternatives. So[~|%7E]means “either a literal~,|,%,7orE.You have to use parens for that. And you should escape the
.in\.aspxbecause.means “any character” in regexes.