I have some expected pattern for data that I receive in my server. The following 2 lines are expected as I wish.
¬14AAAA3170008@¶
%AAAA3170010082¶
So, to check if the data it's fine, I wrote the following regex:
(?<pacote>\\A¬\\d{2}[a-fA-F0-9]{4}\\d{7}.{2})
(?<pacote>\\A[$%][a-fA-F0-9]{4}\\d{10}.)
And it works fine in regex101.com but Java Pattern and Matcher doesn't understand this regex as expected. Here goes my Java code
String data= "¬14AAAA3170008@¶%AAAA3170010082¶";
Pattern patternData = Pattern.compile( "(?<pacote>\\A¬\\d{2}[a-fA-F0-9]{4}\\d{7}.{2})", Pattern.UNICODE_CASE );
Matcher matcherData = patternData.matcher( data );
if( matcherData .matches() ){
System.out.println( "KNOW. DATA[" + matcherData .group( "pacote" ) + "]");
}else{
System.out.println( "UNKNOW" );
}
And it didn't worked as expected. Could someone help me figure what mistake I'm doing?