I use javascript. I need to match a string that would be like this (if I had to describe it with real words):
(NOTHING before) + (only ONE word, not optional) + (".couleur" (it is a "fixed" word)) + (only ONE OPTIONAL SPACE) + ("=" (fixed word)) + (only ONE OPTIONAL SPACE) + (either the word "vert" or "violet" or "orange") + (NOTHING after)
I tried this :
var re1='((?:[a-z][a-z]+))';
var re2='(\\.)';
var re3='(couleur)';
var re4='(\\s?)';
var re5='(=)';
var re6='(\\s?)';
var re7='((?:[a-z][a-z]+))';
var p = new RegExp(re1+re2+re3+re4+re5+re6+re7,["i"]);
But I don't find how to avoid matching when there is something BEFORE and something AFTER my string, and I don't know how to check if the last part is "vert" "orange" or "violet" to match it.
EDIT: here are some string that would match :
"test.couleur = vert"
"te.couleur = violet"
and here are some string that wouldn't match:
" test.couleur = vert" (space before)
" e tdk.couleur = vert" (something before the first word)
"tdl.couleur = vert e" (something after the last word)
"tdk.couleur = gris" (gris is not "vert" or "orange" or "violet")
Thanks a lot for your help!