I need a regular expression for accep开发者_JAVA技巧ting alpha numerics and special charecters also
like : abc & def12
thanks in advance Nagesh
This might be the syntax you are looking for /^[a-zA-Z0-9&:\/ ]+$/
, insert any other characters you want to match between the square brackets.
I would recommend you to read up on regular expressions if you intend to use them in the future, check out this tutorial http://perldoc.perl.org/perlretut.html
^[\w]+$
this regex will match all alphanumerics, if you want to match some other chars as well just specify them in the []
brackets, i.e. if you wan't to also match ampersand you will have ^[\w&]+$
regex, if you wan't to match white characters as well (tabs, spaces, line feeds, carriage returns) you add \d
and end up with ^[\w&\s]+$
and so on until you have all your special characters handled.
not got a specific answer, but regexlib.com has come in handy for me.
精彩评论