내 문자열의 예를 찾아주세요 :정규 표현식 자바
<s id="1">Here we show that <ANAPH id="535" biotype="partof_product">the approximately 600-amino acid; region</ANAPH> something somethingelse .</s>
필요한 기능 (꺾쇠 괄호 포함) 꺾쇠 괄호 동봉 된 시퀀스를 제거하여 문자열을 청소하는 것입니다. 따라서 원하는 출력과 상기 제 예시 문자열 될 경우 :. 정규 표현식
Here we show that the approximately 600-amino acid; region something somethingelse .
= \ < {1} * \> {1}와 완전히 대체 기능을 사용하여, 전체 라인이 대체 얻는다; 왜 그렇게되는지 이해합니다. 누군가가 원하는 출력을 얻기 위해 정규 표현식을 사용하여보다 구체적으로 패턴을 표현할 수있는 방법을 지적 할 수 있습니까?
감사합니다.
EDIT1 :
<s id="7"><ANAPH id="100216" biotype="supertype" assoc_ante="48275" assoc_rel="set-member" coref_chain="set_234">The C. elegans genome sequence</ANAPH> was completed two years ago [ 1 ] , and both the Drosophila [ 2 ] and human genomes are essentially completely sequenced at this point .</s>
출력 : 아래의 문자열을,
그러나 Kassym DORSEL에 의해 제안 된 정규 표현식을 사용
예, 위의 문자열을 촬영할 때주의 에 정규 표현식을 사용하면 다음과 같습니다 :
<ANAPH id="100216" biotype="supertype" assoc_ante="48275" assoc_rel="set-member" coref_chain="set_234">The C. elegans genome sequence</ANAPH> was completed two years ago [ 1 ] , and both the Drosophila [ 2 ] and human genomes are essentially completely sequenced at this point .</s>
원하는 출력은 다음과 같습니다
The C. elegans genome sequence was completed two years ago [ 1 ] , and both the Drosophila [ 2 ] and human genomes are essentially completely sequenced at this point .
당신은 나 정규 표현식을 일반화 도울 수있을 것인가?
은'replaceFirst' 방법은 대체하게됩니다 반면'replaceAll' 방법은 그들 모두를 대체한다 첫번째. 내가 말할 수있는 것은'replaceAll'이 여기에 예상 된 결과를 준다는 것입니다. – MRAB