开发者

regular expression for special chars and numerics

开发者 https://www.devze.com 2022-12-11 02:09 出处:网络
I need a regular expression for accep开发者_JAVA技巧ting alpha numerics and special charecters also

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消