Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:08:49+00:00 2026-05-30T01:08:49+00:00

i continue with this question.Its help and work. regex for special character .My regex

  • 0

i continue with this question.Its help and work.regex for special character.My regex pattern is:

var characterReg = /^\s*[a-zA-Z0-9,\s]+\s*$/;

it accepta-zA-z0-9 only.But i want a regex which also support underscore(_) and das(-).I am unable to modify regex pattern because it is out of my mind.Plz some one suggest a correct pattern for my situation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:08:51+00:00Added an answer on May 30, 2026 at 1:08 am

    var characterReg = /^\s*[a-zA-Z0-9_,\s-]+\s*$/;
    - is a special character and means range if you write it between two chars. So you can escape it (\\-) or just put in the end of []‘s content.
    Actually you can write \\w instead of a-zA-Z0-9_.\\w is a word character (letters, digits, and underscores).
    And also \s* in the end is unnecessary because there is a whitespace in your square braces and [\\w,\s-]+ will match this foo bar-123 wholly
    I think this is better: var characterReg = /^\s*[\\w,\s-]+$/;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Continue Execution Only After .each() Completes This question is actually a continuation
I'm not sure if this question has been asked before, but I can't seem
I know this isn't a straightforward question but I would really appreciate some feedback
This isn't a style question. Its more about the proper use of the language
Solved this ages ago, but this question recently got some attention so I'm adding
Preamble So, this question has already been answered, but as it was my first
I have edited this question but at the bottom of the program I have
This is more or less an academia question to help me better understand this
And my confusion with JSF continues. This is a continuation of a question asked
I continue to get this error: Object '%s' cannot be renamed because the object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.