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.
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
\\winstead ofa-zA-Z0-9_.\\wis 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 thisfoo bar-123whollyI think this is better:
var characterReg = /^\s*[\\w,\s-]+$/;