我想产生两种模式 以下面的信息,
(1) 无法在账户窗体中以名、姓、电子邮件、电话号码字段输入下列特殊字符:
Pattern " [ ] : ; | = + * ? < > / , Names cannot start with a period
(2) 无法在公司地址字段中输入下列特殊字符:
< parcter & lt; & gt; /
请给我个想法
提前感谢
我想产生两种模式 以下面的信息,
(1) 无法在账户窗体中以名、姓、电子邮件、电话号码字段输入下列特殊字符:
Pattern " [ ] : ; | = + * ? < > / , Names cannot start with a period
(2) 无法在公司地址字段中输入下列特殊字符:
< parcter & lt; & gt; /
请给我个想法
提前感谢
< 强 > 尝试这些图案 < / 强 >
用于第一个点
(?i)^([a-z][^"[:]|=+*?<>\/
]+)$
用于第二点
(?i)^([a-z][^<>\/|
]+)$
<强 > Explants 强>
1st Pattern
"(?i)" + -- Match the remainder of the regex with the options: case insensitive (i)
"^" + -- Assert position at the beginning of a line (at beginning of the string or after a line break character)
"(" + -- Match the regular expression below and capture its match into backreference number 1
"[a-z]" + -- Match a single character in the range between “a” and “z”
"[^"\[:\]\|=\+\*\?<>\\\/
]" + -- Match a single character NOT present in the list below
-- The character “"”
-- A [ character
-- The character “:”
-- A ] character
-- A | character
-- The character “=”
-- A + character
-- A * character
-- A ? character
-- One of the characters “<>”
-- A character
-- A / character
-- A carriage return character
-- A line feed character
"+" + -- Between one and unlimited times, as many times as possible, giving back as needed (greedy)
")" +
"$" -- Assert position at the end of a line (at the end of the string or before a line break character)
2nd Pattern
"(?i)" + -- Match the remainder of the regex with the options: case insensitive (i)
"^" + -- Assert position at the beginning of a line (at beginning of the string or after a line break character)
"(" + -- Match the regular expression below and capture its match into backreference number 1
"[a-z]" + -- Match a single character in the range between “a” and “z”
"[^<>\\\/\|
]" + -- Match a single character NOT present in the list below
-- One of the characters “<>”
-- A character
-- A / character
-- A | character
-- A carriage return character
-- A line feed character
"+" + -- Between one and unlimited times, as many times as possible, giving back as needed (greedy)
")" +
"$" -- Assert position at the end of a line (at the end of the string or before a line break character)
<强度 > 代码 强度 >
try {
boolean foundMatch = subjectString.matches("(?i)^([a-z][^"\[:\]|=+*?<>\\/\r\n]+)$");
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
您可以使用 < code> string. contains () 方法,而不是使用您显然不信任的正则表达式。
但是,如果你必须使用正gex,就像Mayur Patel所说的,“[ab]
”基本上是指 a 或 b! 您应该检查正则表达式。 info
下面是解决我问题的办法
1) (?i)^([a-z][^"[:]|=+*.?<>\/ ]+)$
2) (?i)^([a-z][^"<>|\/ ]+)$
我还在1处添加了周期符号,用于检查不以周期符号启动名称。
非常感谢赛连和安迪的帮助 这真的帮了我很多
再次感谢:)
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...