태그를 제거하고 태그 사이에 선택한 텍스트를 위쪽으로 만들고 싶습니다. 방법을 모르십니까?
var pattern = 'We are <orgcase>liViNg</orgcase> in a <upcase>yellow submarine</upcase>.'
var myRegexp = /<upcase>(.*?)<\/upcase>/g;
var match = "$1";
var str = pattern.replace(myRegexp, match.toUpperCase());
console.log(str);
replace
콜백과 함께 사용 하면 일치하는 값을 제공하고 처리 할 수 있습니다.
var str = 'We are <orgcase>liViNg</orgcase> in a <upcase>yellow submarine</upcase>.'
var str = str.replace(/<upcase>(.*?)<\/upcase>/g, function($0) { return $0.toUpperCase(); });
alert(str);
태그 제거에 관해서는 :
str = str.replace(/<\/?[^>]+>/g, '');
바이올린 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다