Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "string1", "string2"
- $string = "
- iojefu { string1 }
- asdjhu { string2 }
- ";
- preg_match_all('/{s*(?P<str>[^}]+?)s*}/', $string, $matches);
- var_dump($matches['str']);
- /*
- array(2) {
- [0] => string(7) "string1"
- [1] => string(7) "string2"
- }
- */
- $matches = [];
- preg_match_all('/{s*([^}s]*)s*}/', $string, $matches);
- /[{]s*([^{}]+)s*[}]/
- $array = preg_split('/.*?{|}|s/', $string, null, PREG_SPLIT_NO_EMPTY);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement