2

私はストラット1.2を使用しています。文字を拒否する検証を設計する必要があります%,/,?,<,>。最後の2文字をエスケープする必要があることを確認できますが、ストラットで正規表現の特定のルールを見つけることができません.

4

2 に答える 2

0
String str; //the string to check - load it up with the value from the form
....

if(str.contains("%") || str.contains("/") || str.contains("?") || str.contains("<") || str.contains(">")){
  //string contains invalid chars
}else{
  //string contains vaild chars
}

正規表現は関与せず、文字をエスケープする必要はありません:)-より良い方法があるかもしれませんが。

于 2011-03-03T17:14:35.210 に答える
0

これはあなたを助けるかもしれません

<constant>
      <!--All characters except < > " ' & % ; | and ~-->
      <constant-name>allchars</constant-name>
      <constant-value>^[^&lt;&gt;&quot;&apos;&amp;%;|~]*$</constant-value>
 </constant>
于 2012-12-28T09:24:58.427 に答える