php - Get font name from Google Fonts URL with regular expression -


please tell me how preg_match font names google fonts url.

for example, want extract font name from:

http://fonts.googleapis.com/css?family=oswald:400,300 http://fonts.googleapis.com/css?family=roboto+slab 

in order font names oswald , roboto slab.

here's example of might preg_replace(), careful data mining google.

<?php $urls = array("http://fonts.googleapis.com/css?family=oswald:400,300", "http://fonts.googleapis.com/css?family=roboto+slab");  $patterns = array(       //replace path root '!^http://fonts.googleapis.com/css\?!',       //capture family , avoid , following attributes in uri. '!(family=[^&:]+).*$!',       //delete variable name '!family=!',       //replace plus sign '!\+!'); $replacements = array( "", '$1', '', ' ');  foreach($urls $url){     $font = preg_replace($patterns,$replacements,$url);     echo $font;  }  ?> 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -