Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. "string1", "string2"
  2.  
  3. $string = "
  4. iojefu { string1 }
  5. asdjhu { string2 }
  6. ";
  7. preg_match_all('/{s*(?P<str>[^}]+?)s*}/', $string, $matches);
  8. var_dump($matches['str']);
  9. /*
  10. array(2) {
  11. [0] => string(7) "string1"
  12. [1] => string(7) "string2"
  13. }
  14. */
  15.  
  16. $matches = [];
  17. preg_match_all('/{s*([^}s]*)s*}/', $string, $matches);
  18.  
  19. /[{]s*([^{}]+)s*[}]/
  20.  
  21. $array = preg_split('/.*?{|}|s/', $string, null, PREG_SPLIT_NO_EMPTY);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement