# replace tag ( B tag to strong )
```javascript
String.prototype.replaceTag = function(a,b) {
var input = a.join("|");
debugger;
var reg = new RegExp( '<(/?)(' + input + ')\\b((?:[^>"\']|"[^"]*"|\'[^\']*\')*)>',"gim");
if(reg.test(this)){
console.info( 'ok' );
//alert ( 'ok' );
}
//alert(input.replace(reg,"<$1Strong$3>"));
//console.info(this.replace(reg,"<$1" + b + "$3>"));
return this.replace(reg,"<$1" + b + "$3>");
}
console.info("\n\n\n\n\n\n"
.replaceTag(["script","div"],"Strong"));
```
'web > javascript' 카테고리의 다른 글
Javascript Module (0) | 2019.07.12 |
---|---|
Javascript arrow function expression (0) | 2019.07.12 |
bind click event loop index (0) | 2019.07.12 |
Javascript Async, Await 심화 (0) | 2019.07.12 |
Javascript Async return Promise For await (0) | 2019.07.12 |
댓글