나는 답을 내기가 나에게 쳐다보고 있기 때문에 바보 같은 질문을하지만 여기에 간다.테스트가 수행 할 때 정규식 객체로 작업을 대체하지 않는 이유는 무엇입니까?
CSS 스타일 textDecoration에서 문자열을 가져 와서 문자열의 밑줄 부분 (및 주위의 공백)을 제거하려고합니다. 그것은 test()를 실행할 때 true를 반환하지만 replace 메서드를 수행하면 문자열이 변경되지 않습니다. 도움?
내 코드 :
출력textDecoration = function(str) {
var n_str = str + '|/\s' + str + '|/\s' + str + '/\s|' + str + '/\s';
var nre = new RegExp(n_str, "g");
debug_log('Found or not: ' + nre.test(txt));
txt.replace(nre, '');
debug_log('Result: ' + txt);
debug_log('-----------------------');
}
var txt = "underline";
debug_log('-----------------------');
debug_log('Starting String: ' + txt);
textDecoration("underline");
txt = "underline overline line-through";
debug_log('-----------------------');
debug_log('Starting String: ' + txt);
textDecoration("underline");
txt = "overline underline line-through";
debug_log('-----------------------');
debug_log('Starting String: ' + txt);
textDecoration("underline");
txt = "overline line-through underline";
debug_log('-----------------------');
debug_log('Starting String: ' + txt);
textDecoration("underline");
:
나는 당혹 스럽다. 고마워. 나는 T-Minus에서 8 분을 받아 들일 것이다. –