需要正则表达式来验证字符串 [英] Require regular expression to validate a string

查看:98
本文介绍了需要正则表达式来验证字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想做一个正则表达式来验证特定类型的字符串.

验证字符串的条件如下:

-字符串中不得包含\(反斜杠),/(正斜杠),:(冒号),*(星号)、?等字符. (问号),(双引号),<(左尖括号),>(直角括号),|(竖线)
-不要包含连字符(-)或句点(.)作为字符串的第一个或最后一个字符.

我做了很多尝试,但没有成功,因为我需要一个满足所有条件的正则表达式.

Hello All,

I want to make a regular expression which will validate string of particular type.

The conditions to validate string are as follows:

- String should not contain characters like \ (backslash), / (forward slash), : (colon), * (asterisk), ? (question mark), " (double quotes), < (left angle bracket), > (right angle bracket), | (pipe)
- Do not contain a hyphen (-) or a period (.) as the first or last character of a string.

I tried a lot but not getting any success as I require single regular expression fulfilling all conditions.

推荐答案

最后从stackoverflow.com获得了答案

http://stackoverflow.com/questions/12667944/require-regular-expression- to-validate-a-string [ ^ ]
Finally got the answer from stackoverflow.com

http://stackoverflow.com/questions/12667944/require-regular-expression-to-validate-a-string[^]


这篇关于需要正则表达式来验证字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆