Ex: I have a string “my str [str]string string[/str] my str [str]string string[/str] kjnvjsfn”
I`ve tried to do so with RegExp like this
preg_match_all('/\[str](.|\n|\r\n)*\[\/str\]/', $str, $arr);
but it cuts whole string till last [/str]
Thanks.
Make it non-greedy: Use
*?instead of*However, regexes are probably not the best way to go. I.e., it may be sufficient for your purpose (if you’re e.g. writing them yourself). But if “tags” can be nested then you’ll find that the regex approach is becoming very cumbersome.