http://www.perlmonks.org?node_id=185334


in reply to regexp problem using custom markup

This code should work: @colors = $new =~ m/(\[color=.*?\])/gi;

First off, @colors will receive values that are kept by parentheses, and you don't have any in your regex.

And second, the .* in your regex will make it match "[color=blue] blue [/color] word. And a [color=red] red [/color]" all at once because regexes are greedy -- they match as much as possible. By adding the ? behind .* it matches as little as possible.

elusion : http://matt.diephouse.com