What is the regular expression to accept only text, number and backslash. It should not accept space and should start with text only. For example domain\username. Thanks in advance...
this is a regex for domain\name with the restriction that 'domain' should start with a char and end with a char. You can easily maniplate the regex for your desire
/^[a-zA-Z][a-zA-Z0-9-]{1,61}[a-zA-Z]\.[a-zA-Z]{2,}$/
Domain - Beginning:
[a-zA-Z] Text
Domain - Text:
1-61 times of [a-zA-Z0-9-] Text, Numbers, '-'
Domain - End:
1 time [a-zA-Z] = Text
Backslash:
1 time [\]
User - Text:
2-infinity times [a-zA-Z] = Text
Edit: as bgh pointed out in the comment you could include more valid characters
/^[a-zA-Z][a-zA-Z0-9\-\.]{0,61}[a-zA-Z]\\\w[\w\.\- ]*$/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With