StasKh
StasKh

Reputation: 23

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?

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

Upvotes: 0

Views: 91

Answers (2)

Alex Nikulin
Alex Nikulin

Reputation: 8679

Use this code

 document.querySelectorAll("table[border]")

Upvotes: 3

Raghavendra
Raghavendra

Reputation: 3580

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);

Upvotes: -1

Related Questions