How do I search for a string that contains only chars from a set including x, and require it to contain x? e.g. [a-z]+ but not matching if it doesn
Assuming you want to match a string of only x,y or z, match start (^) followed by zero or more y or z ([yz]*) followed by an x followed by zero or more x, y or z ([xyz]*) followed by end ($)
^[yz]*x[xyz]*$
If you are trying to match [a-z] but with an x in there somewhere, then this should do it
^[a-z]*x[a-z]*$
try something like this
^[a-z]*x[a-z]*$
[a-z]*x[a-z]* should do the trick.