我有正则表达式在 Javascript 中工作,现在我想将它们翻译成 Java:
var nat_pattern2 = /^\d{8}$/;
var nat_pattern2 = /^\d{7}\-\d{1}$/;
var pct_pattern1 = /^\PCT\/?[A-Z]{2}?\d{4}\/\d{6}$/;
var ing pct_pattern2 = /^\PCT[A-Z]{2}\d{10}$/;
var pct_pattern3 = /^\P[A-Z]{2}\d{8}$/;
var its_pattern1 = /^\ITS\/?[A-Z]{2}?\d{2}\/\d{5}$/;
var its_pattern2 = /^\ITS[A-Z]{2}\d{7}$/;
var its_pattern3 = /^\I[A-Z]{2}\d{7}$/;
我的开头看起来像这样,但它不正确:
Pattern pattern = Pattern.compile("/^\d{8}$/");
你能帮助我吗?