Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Redirection Plugin case insensitive regular expression

I am a total regex rookie and I'm trying to take advantage of the regex option in the WordPress Redirection plugin to have a case insensitive match of a word so that: www.mydomain.com/someword will redirect to an appropriate paypal page.

by case insensitive I mean any and all variations of capitalization (e.g SomeWord, somEWord, SomeworD, etc)

I've tried:

(?:^|\W)someword(?:$|\W)
(?:^|\W)someword(?:$|\W)
^/(\b\Wsomeword\W\b)
^/(\W\bsomeword\b\W)
^/(?i\bsomeword\b)
/(\bS|sO|oM|mE|eW|wO|oR|rD|d\b)

but I'm really just dicking around. Any help would be greatly appreciated.

like image 709
Lee Mandell Avatar asked Oct 28 '25 09:10

Lee Mandell


1 Answers

Let me explain what each of your attempts mean:

  • (?:^|\W)someword(?:$|\W) - either the start of the string or one non-word character, followed by someword, followed by the end of the string or a non-word character
  • ^/(\b\Wsomeword\W\b) - the start of the string, forward slash, followed by a word boundary, followed by a non-word character (you already have a contradiction here), followed by someword, followed by a non-word character, followed by a word boundary
  • ^/(\W\bsomeword\b\W) - same with non-word characters and word boundaries switched
  • ^/(?i\bsomeword\b) start of string, followed by forward slash, followed by ?!
  • /(\bS|sO|oM|mE|eW|wO|oR|rD|d\b) - forward slash, followed by either a word boundary and S or sO or oM or mE or eW or wO or oR or rD or d and a word boundary

Word character - either an English letter, a digit or underscore.

Word boundary - a place where on one side you have a word character and on the other, something, which is not a word character.


Now as for a solution:
(?i)\/someword$

Meaning case insensitive, there is a slash and someword, followed by the end of the string.

like image 149
ndnenkov Avatar answered Oct 31 '25 07:10

ndnenkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!