Reputation: 143
I want to check that an underscore is obligatorily between two letters or spaces.
For example :
"-ayui" : not good
"jjdk-jk" : good
"hd -sdjh" : good
"fgggdf-" : not good
"hjhfs - jgkd" : good
" kf8-1dd" : not good
Can you help me ?
Thanks very much !
Upvotes: 0
Views: 1732
Reputation: 163277
Looking at your example data, I think you mean hyphen instead of underscore.
If that is the case, you could use ^[a-z]+\s*-\s*[a-z]+$
to match:
^
[a-z]+
\s*
-
\s*
[a-z]+
$
Upvotes: 3