You have to do some tasks again and again in your life as a developer. This chapter contains several useful examples.
Web and Network
The expressions in this section are dedicated to web and network environments.
HTML Tags
This is how you look for an HTML tag with the fixed name DIV:
/<DIV\b[ˆ>]*>(.*?)<\/DIV>/i
And this expression looks for any tag:
/<([A-Z][A-Z0-9]*)\b[ˆ>]*>(.*?)<\/\1>/i
Once again, I’m using a \1 reference on the first hit to find the matching closing tag.
1 var patt = /<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)<\/\1>/i;
2 var html = "Ww want write <b>bold</b> and <i>italic</i> here";
3 console.log(patt.exec(html)); ...