javascript regex to get tag attribute value

I am using below regex to find the content of title tag in a given string:

alert("<title  >kjkj</title><title>jjjjj</title>".match(/<title[^>]*>([^<]+)</title>/)[1]);

Next I want to find the content of meta property="og:title" :

<meta property="og:title" content="The Rock" /> is a string

I have no clue how to do that. I can’t use jQuery or create any DOM element. Its pure a string and i have to work on a given string only

Source: regex

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.