Last active
January 16, 2019 17:46
-
-
Save SethVandebrooke/1487698da3e80c02344f86deea9cd34b to your computer and use it in GitHub Desktop.
Regex expression for getting string starting with something and ending with something else
This file contains hidden or 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 | |
//start with $ end with ) | |
preg_match_all('/\$.+?(?=\))/', '<p>$test(hello)</p> <p>$test(testing)</p>', $matches, PREG_UNMATCHED_AS_NULL); | |
print_r($matches); | |
/* | |
Array | |
( | |
[0] => Array | |
( | |
[0] => $test(hello | |
[1] => $test(testing | |
) | |
) | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment