Escaping using \-
should be fine, but you can also try putting it at the beginning or the end of the character class. This should work for you:
/^[a-zA-Z0-9._-]+$/
More Related Contents:
- javascript regex for password containing at least 8 characters, 1 number, 1 upper and 1 lowercase [duplicate]
- Not able to get Regular Expression in javascript
- Need Pattern for password field?
- Regex for Email Address along with name format [duplicate]
- Regular Expression jquery validation1 [duplicate]
- Regular expression to match non-ASCII characters?
- jQuery selector regular expressions
- Regex to replace multiple spaces with a single space
- Regex pattern to match at least 1 number and 1 character in a string
- Extract hostname name from string
- How to pull the file name from a url using javascript/jquery?
- How do I remove javascript validation from my eclipse project?
- Validate phone number using javascript
- How can I select an element by ID with jQuery using regex?
- Regex to Match Symbols: !$%^&*()_+|~-=`{}[]:”;’?,./
- Javascript regex returning true.. then false.. then true.. etc [duplicate]
- Simulate drop file event
- jquery only allow input float number
- Example of a regular expression for phone numbers
- Highlight current page in jquery
- What is jQuery Unobtrusive Validation?
- JavaScript Regex to match a URL in a field of text
- Regex in JavaScript for validating decimal numbers
- regular expression to validate datetime format (MM/DD/YYYY) [duplicate]
- Max characters in textarea with jquery
- Form Validation With Bootstrap (jQuery)
- JavaScript validation issue with international characters
- How to highlight a part part of an Input text field in HTML using Javascript or JQuery
- Match all URLs in string and return in array in JavaScript
- Regular Expression to MATCH ALL words in a query, in any order