Skip to content

Instantly share code, notes, and snippets.

@SethVandebrooke
Last active January 16, 2019 17:46
Show Gist options
  • Save SethVandebrooke/1487698da3e80c02344f86deea9cd34b to your computer and use it in GitHub Desktop.
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
<?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