Created
December 5, 2012 23:24
-
-
Save davepoon/4220464 to your computer and use it in GitHub Desktop.
PHP Regex to get src value
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
<?php | |
$input_string = '<script type="text/javascript" src="http://localhost/assets/javascript/system.js" charset="UTF-8"></script>'; | |
$count = preg_match('/src=(["\'])(.*?)\1/', $input_string, $match); | |
if ($count === FALSE) | |
echo('not found\n'); | |
else | |
echo($match[2] . "\n"); | |
$input_string = "<script type='text/javascript' src='http://localhost/index.php?uid=93db46d877df1af2a360fa2b04aabb3c' charset='UTF-8'></script>"; | |
$count = preg_match('/src=(["\'])(.*?)\1/', $input_string, $match); | |
if ($count === FALSE) | |
echo('not found\n'); | |
else | |
echo($match[2] . "\n"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool