Home > DeveloperSection > Forums > Need a regex to get font name and weight in a google fonts stylesheet path
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    October-05-2013 2:46 AM

 HTML5 HTML5 
Ratings:


 1 Reply(s)
 919  View(s)
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 



F Scott Fitzgerald
F Scott Fitzgerald

Total Post:29

Points:203
Posted on    October-05-2013 4:23 AM

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

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

Don't want to miss updates? Please click the below button!

Follow MindStick