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

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -