이것은 입력 문자열이며 다음 정규 표현식에 따라 5 부분으로 나눠서 5 개의 그룹을 인쇄 할 수 있지만 항상 일치하는 항목이 없습니다. . 내가 도대체 뭘 잘못하고있는 겁니까 ?문자열을 5 부분으로 나눌 수있는 정규 표현식
String content="beit Be it enacted by the Senate and House of Representatives of the United States of America in Congress assembled,,<m>Surface Transportation Extension Act of 2012.,<xm>";
Pattern regEx = Pattern.compile("^(.*)(<m>)(.*)(<xm>)(.*)$", Pattern.MULTILINE);
System.out.println(regEx.matcher(content).group(1));
System.out.println(regEx.matcher(content).group(2));
System.out.println(regEx.matcher(content).group(3));
System.out.println(regEx.matcher(content).group(4));
System.out.println(regEx.matcher(content).group(5));
jlordo, 나는 궁극적으로 이것을하고 싶다 : "regEx.matcher (content) .replaceAll (replaceExpression)"과 나의 replaceExpression은 다음과 같다 : "$ 1 <marginal> $ 3 </marginal > $ 5" – Phoenix
@Phoenix : 문제가 어디에 있습니까? 당신은 당신의 질문에 전혀 언급하지 않았습니다. – jlordo
@jlordo : 그는 첫 번째 질문 [여기] (http://stackoverflow.com/questions/16903315/why-doesnt-the-following-regex-work-when-input-through-spring)을 요청했지만하지 않았다. 50 분 (헐떡 거림!) 동안 대답을 가지고, 그는 다른 사람에게 물었다. –