0

So, I have a series of regex redirections for some help topics.

Example:

(?i)\/msa/HelpOnline/source/helpoptionsemailgoogle.htm$

If the user had used the search tab in the old help system and clicked on the same link for the above topic the resulting link was:

/msa/helponline/index.html?page=source/helpoptionsemailgoogle.htm

So, I have an option bit of URL that might be present:

/msa/helponline/[index.html?page=]source/helpoptionsemailgoogle.htm

Is it possible with regex to optionally allow for that text so that with the same redirection we can find:

/msa/helponline/source/helpoptionsemailgoogle.htm
/msa/helponline/index.html?page=source/helpoptionsemailgoogle.htm

I am using the Wordpress Redirection plugin and the redirections are being stored with Wordpress.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • 1
    Possible duplicate of [How to write optional word in Regular Expression?](https://stackoverflow.com/questions/32566087/how-to-write-optional-word-in-regular-expression) – Andrew Truckle Jun 16 '18 at 13:34

1 Answers1

0

This works:

(?i)\/msa/HelpOnline/(index.html\?page=)?source/helpoptionsemailgoogle.htm$
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164