入力としてxmlを受け取り、正規表現を使用してタグ内の許容文字のリストをチェックするJavaプログラムがあり、この特殊文字のような許容文字以外を含むタグ全体を返す必要があります
XML入力
<?xml version="1.0"?>
<PayLoad>
<requestRows>****</requestRows>
<requestRowLength>1272</requestRowLength>
<exceptionTimestamp>2012070202281068-0700</exceptionTimestamp>
<exceptionTimestamp>201$2070202281068-0700</exceptionTimestamp>
<exceptionTimestamp>20120(702022810680700</exceptionTimestamp>
<exceptionDetail>NO DATA AVAILABLE FOR TIME PERIOD SPECIFIED =</exceptionDetail>
</PayLoad>
許容文字リスト
\! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~
私は以下のように試しました
public static void main(String args[])
{
List<String> specialCharList = new ArrayList<String>();
try{
String responseXml="test";
String SPECIAL_CHARACTER ="(<[\\w\\d]*>(?=[^<]*[^<\\w\\!\\#\\$\\%\\&\\\'\\(\\)\\\\ \\*\\\"\\+\\,\\-\\~\\}\\{\\.\\/\\:\\;\\=\\?\\@\\]\\[\\\\\\`\\|]).*</[\\w\\d]*>)";
if (!(responseXml == null || responseXml.toString().length() < 1 || responseXml.toString().equals("")))
{
Pattern patternObject = Pattern.compile(SPECIAL_CHARACTER);
Matcher patternMatcher = patternObject.matcher(responseXml);
while(patternMatcher.find())
{
specialCharList.add(patternMatcher.group());
}
if(specialCharList.isEmpty() || specialCharList.size()<0)
{
specialCharList.add("No Special Character's Detected");
}
}
}catch(Exception e)
{
}
System.out.println(specialCharList);
}
しかし、期待どおりに機能していません。上記のシナリオの正規表現を作成するにはどうすればよいですか? 助けてください