I am trying to create a regular expression that checks for letters, numbers, and underscores. In .NET, I can do “^\w+$”. However, I am not that familiar with the JavaScript syntax. Can somebody help me out?
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One obvious difference is that in JavaScript, you write the regex as
/pattern/flags— this is Perl-style. Your “example” would then be^\w+$→/^\w+$/.For example, replace multiple
e‘s with onee, case-insensitive search (hence theiflag):Returns:
qwerty.