I wish to know how to test strings composed of certain string and characters. I've tested
/translate+x|y|z/i.test('translateX')returnstrue/translate+x|y|z/i.test('translate')returnsfalse/translate+x|y|z/i.test('rotateX')returnsfalse
So with other words, I need to know if the string is translateX or translateY or translateZ but I am not sure if I have / don't have to escape the + there. Also please DO suggest a better all round, cross-browser solution that can be shorter / more precise.
\+matches a literal+and in your pattern,+is a quantifier allowing to match severaleaftertranslat./translate[xyz]?/iwhat he meanstranslateXortranslateYortranslateZin a very short and efficient.test()call./^translate[XYZ]$/.test(text)