그래서 regexp를 연결하는 방법이 있는지 궁금합니다. 내 코드를 조금만 최적화하려고합니다. 표현을 찾고 결과에서 다른 표현을 찾고 싶습니다.jQuery Regexp를 연결할 수 있습니까?
실무 코드 :
match = $('body').html().match(/(\[~\{ .*? \}~\])(\w+)/g);
console.log(match[0]);
표현 하나의 오류
match = $('body').html().match(/(\[~\{ .*? \}~\])|(\w+)/g);
console.log(match[0]);
표현 하나를 찾을 다음을 찾을 표현이 외부 생산 : 나는 무엇을 시도했다
match = $('body').html().match(/(\[~\{ .*? \}~\])/g);
console.log(match[0]);
findText = match[0].match(/\w+/);
console.log(findText);
.
내 HTML은 :
[~{ header }~]
<p>This is the home page</p>
[~{ footer }~]
부분. '.match()'는 jquery 함수가 아닌 javascript 문자열 함수이므로, ti는 (오류 제어와 함께) 연결을 어렵게하는 결과 배열 (nothign이 일치하면 null)을 반환합니다. 여기 실제로 습득하려고하는 건 뭐니? – Adam
본문에서 [~ {anything} ~]을 찾은 다음 찾은 것으로부터 추출합니다. – jemiloii
작업 코드 섹션은 내가하고 싶은 작업을 정확히 수행합니다. – jemiloii