I have this little code to capture text between brackets:
$string = '[title=my title] http://bit.ly/gANFxi [maps:some cool place]';
preg_match_all('/\[([^\]]*)\]/', $string, $matches);
print_($matches[0]);
What I get is the following:
Array(
[0] => [title=my title]
[1] => [maps:some cool place]
)
I want to make more restrictive to avoid “[some-not cool]” or “[another+stuff]”,
so I need to catch only [some:thing] and [some=thing].
How can I do it?
This will catch everything that contains a ‘=’ or ‘:’ and ignore others:
Does this do the trick? Or are there further requirements? That is, this return “[some stuff=some:thing]” but should it? (note both the multiple words and both ‘=’ and ‘:’).