How to get all captures of subgroup matches with preg_match_all()? [duplicate]

Similar thread: Get repeated matches with preg_match_all() Check the chosen answer plus mine might be useful I will duplicate there: From http://www.php.net/manual/en/regexp.reference.repetition.php : When a capturing subpattern is repeated, the value captured is the substring that matched the final iteration. I personally give up and going to do this in 2 steps. EDIT: I see … Read more

Php preg_match_all, wordpress function [closed]

The code you found on the internet is kind of irrelevant. In order to achieve what you want you need something like this: $str = “[image name=ubuntustudio-tribal-54] “; $pat = “~\[image name=([^\]]+)~i”; preg_match($pat, $str, $matches); $name = $matches[1]; After that $name would be bound to ubuntustudio-tribal-54. See the docs for more details regarding PHP’s preg_match. … Read more