简体   繁体   中英

Find html tags using RegEx in JavaScript

I need to fing all "table" tags on page with attribute border on the page using Regular Expressions on JavaScript.

How can I do it?

PS Please, don't propose me any JQuery (or similar) solutions.

使用此代码

 document.querySelectorAll("table[border]")

you can use regex object like this to match table which has border.

myTableElement.match(/<table.*?border.*?>.*?<\/table>/gi)

or like this

var x =  new RegExp(/<table.*?border.*?>.*?<\/table>/gi)

myTableElement.match(x);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM