in reply to PMML - Perlmonks Markup Language
You could make your converter stronger with a couple of fixes.
Regular expressions could be made case insensitive with the i modifier.
More important, if more than one <cpan> element is present in one line, .* will act greedily and gobble more than what you intend to gobble.
For example
<cpan>First::module</cpan> and <cpan>Second::Module</cpan>
will be collapsed into
[cpan://First::Module</cpan> and <cpan>Second::Module]
which is certainly wrong.
You can make * non greedy adding ?:
<cpan>(.*)</cpan> becomes <cpan>(.*?)</cpan>
Other than this, you may want to check Death to Dot Star! for a number of reasons why .* should be avoided when possible.
-- TMTOWTDI
|
|---|