I am using this code but it doesn’t work correctly for – (mains) symbol
^\b\w{1,}(_\.-)?\w\b$ or ^\b\w{1,}(_\.\-)?\w\b$
The code above doesn’t work if string is like this: name-name
What I want to do with this code is:
Name most begin with Alphanumeric and aslo end, it can have this symbols (.-_) but only in the middle
name => true
Name_ => false
Name_sa => true
name._ => false
name.-as => false
I think this should do it:
Here the
[^\W_]matches only any character except non-word characters and the_, so basically any word character except_. This is necessary as\wdoes contain_.