Created
March 4, 2010 03:22
-
-
Save pedromenezes/321364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$str = "{ id: 'div-2340796981343853667', | |
site: '07472483417241913304' },"; | |
function get_that_stuff ($string){ | |
preg_match("/site: '([^']+)'/", $string, $match); | |
// [^']+ serve pra casar os caracteres que não sejam aspas simples. | |
// os parênteses são grupos de captura. O que casar com o que estiver dentro das aspas será gravado no $match | |
return $match[1]; | |
// o 1 é somente o que está dentro do grupo de captura. O que está em 0 é "site: '07472483417241913304'" que é o que minha expressão regular bateu | |
} | |
print get_that_stuff($str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment