/[\w!@#$%^&()\-'{}\.~]{1,15}/g
This is a regular expression which validates NetBIOS computer names and NetBIOS domain names, as described in this Microsoft article "Naming conventions in Active Directory for computers, domains, sites, and OUs": https://support.microsoft.com/en-us/kb/909264
This is, however, not an attempt to fully validate the name, but to validate the following aspects:
[quote]
Allowed characters
NetBIOS computer names can contain all alphanumeric characters except for the extended characters that are listed in the "Disallowed characters" section. Names can contain a period, but names cannot start with a period.
Disallowed characters
NetBIOS computer names cannot contain the following characters:
backslash (\)
slash mark (/)
colon (:)
asterisk (*)
question mark (?)
quotation mark (")
less than sign (<)
greater than sign (>)
vertical bar (|)
Minimum name length
1 character.
Maximum name length
15 characters.
[/quote]
ValidNames
(See https://support.microsoft.com/en-us/kb/909264)
============
A
AB
ABC
JUST_RIGHT___15
10.10.22.121
MyPC.local.org
Sales.jeefawoij
MyComputer
B-Lee@Gym.com
InvalidNames
============
TOO_LONG______16
VERY_LONG__________20
BLANK SPACE 15
Allowed Characters:
(See https://support.microsoft.com/en-us/kb/188997)
============
YesExcl!Here
YesAt@Here
YesHash#Here
YesDollar$Here
YesPct%Here
YesCaret^Here
YesAmp&Here
YesBrack(Here)
YesMinus-Here
YesSQuote'Here
YesCurl{Here}
YesDot.Here
YesTilde~Here
Illegal Characters:
(See https://support.microsoft.com/en-us/kb/188997)
============
NoBlank Here
NoBackSlash\Here
NoAsterisk*Here
NoPlus+Here
NoEqual=Here
NoPipe|Here
NoColon:Here
NoSemiColon:Here
NoDblQuote"Here
NoQMark?Here
NoLT<Here
NoGT>Here
NoComma,Here