package sample.main;
import org.apache.poi.ss.formula.functions.T;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class whileTest {
public static void main(String[] args) throws InterruptedException {
String str = "5d0d6dd2837312c20323032290000";
String pattern = "(3[0-9]){2,3}";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str);
while (m.find()){
System.out.println(m.group(0));
}
}
/**
* 2022年9月25日22:58:42
* 16进制转Ascii
* @param hexStr
* @return
*/
public static String hexToAscii(String hexStr) {
StringBuilder output = new StringBuilder("");
for (int i = 0; i < hexStr.length(); i += 2) {
String str = hexStr.substring(i, i + 2);
output.append((char) Integer.parseInt(str, 16));
}
return output.toString();
}
}
output
3731==71
323032==202
java-正则 从16进制字符串中找出数字
于 2022-09-24 12:48:45 首次发布