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.
See also, this great source of info about Regular Expressions in general.

Leave a Comment