Alternation operator inside square brackets does not work

javascript, regex

Solution

replace `[wd|word|qw]` with `(wd|word|qw)` or `(?:wd|word|qw)`.

`[]` denotes character sets, `()` denotes logical groupings.

Problem

I'm creating a javascript regex to match queries in a search engine string. I am having a problem with alternation. I have the following regex: ``` .*baidu.com.*[/?].*wd{1}= ``` I want to be able to match strings that have the string 'word' or 'qw' in addition to 'wd', but everything I try is unsuccessful. I thought I would be able to do something like the following: ``` .*baidu.com.*[/?].*[wd|word|qw]{1}= ``` but it does not seem to work.

Original source