NEED A REGEX TO GET FONT NAME AND WEIGHT IN A GOOGLE FONTS STYLESHEET PATH

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
HTML5 
 1243  View(s)
Ratings:
Rate this:

Let's say I have this string:

<link href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,600,700" rel="stylesheet" type="text/css">

I need to remove the text before and after "Open+Sans:400italic,400,300,600,700"

Any of you code-wizards who knows how to make a regex for this? Or is there a better way than using 

  1. F Scott Fitzgerald

    Post:29

    Points:203
    Re: Need a regex to get font name and weight in a google fonts stylesheet path

    A Perl style regex perhaps too much crafted for your example:

    s/<link href="[^"]*family=([^"]*)".*/$1/

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!