정규식에서 일치하는 모든 결과를 반환하는 방법은 무엇입니까?정규식 검색의 모든 결과를 어떻게 반환할 수 있나요?
저는 JMP 18.1.2를 사용하고 있습니다.
Names Default To Here( 1 );
string = "I am looking for ^this^, ^that^, and sometimes ^those^.";
result = Regex( string, "\^([^\n]*?)\^" ); // Only returns first match.
자동화 및 스크립팅데이터 접근윈도우Re: 정규식에서 일치하는 모든 결과를 반환하는 방법?정규식 일치() 함수가 작동할 수도 있습니다.
Re: 정규식에서 일치하는 모든 결과를 반환하는 방법?의견을 주셔서 감사합니다. Regex Match()는 여전히 모든 결과를 반환하지 않습니다. 적어도 제가 쓴 방식으로는 그렇지 않습니다.
Names Default To Here( 1 );
string = "I am looking for ^this^, ^that^, and sometimes ^those^.";
result = Regex( string, "\^([^\n]*?)\^" ); // Returns "^this^".
Show( result );
results = Regex Match( string, "\^([^\n]*?)\^" ); // Returns {"^this^", "this"}.
Show( results );Re: 정규식에서 일치하는 모든 결과를 반환하는 방법?제가 아는 한 Regex(또는 Regex Match)만 사용해서는 현재로선 불가능합니다. Regex Match()에 플래그를 추가하여 pattern의 모든 겹치지 않는 발생을 찾습니다 . Python을 사용할 수 있지만 루프가 있는 JSL을 사용할 수도 있습니다.
Names Default To Here(1);
string = "I am looking for ^this^, ^that^, and sometimes ^those^.";
result = Regex(string, "\^([^\n]*?)\^"); // Only returns first match.
matches = {};
While(!Is Missing(result = Regex(string, "\^([^\n]*?)\^")),
Substitute Into(string, result, "");
Insert Into(matches, result);
);
show(matches); // matches = {"^this^", "^that^", "^those^"};
또는 훨씬 더 복잡한 JMP의 "자체" 패턴 매칭 스크립팅 가이드 > 데이터 유형 > 패턴 매칭 옵션
Re: 정규식에서 일치하는 모든 결과를 반환하는 방법?감사해요!
Re: 정규식에서 일치하는 모든 결과를 반환하는 방법?Jarmo의 방법론과 함께 JMP의 Word() 함수를 사용하면 문제를 해결할 수 있습니다.
Names Default To Here(1);
string = "I am looking for ^this^, ^that^, and sometimes ^those^.";
result = Regex(string, "\^([^\n]*?)\^"); // Only returns first match.
matches = {};
While(!Is Missing(result = word(2,string, "^")),
Substitute Into(string, "^"||result||"^", "");
Insert Into(matches, result);
);
show(matches); // matches = {"^this^", "^that^", "^those^"};
matches = {"this", "that", "those"};