|Problems? Is your data what you think it is?|
Challenge: Transforming markupsby LanX (Chancellor)
|on Dec 06, 2013 at 21:22 UTC||Need Help??|
LanX has asked for the
wisdom of the Perl Monks concerning the following question:
Now links which are freely included in text are tricky...
for instance http://www.gmx.de or CamelCaseLink are valid links for kwiki ...
... and [[http://gmx.de][BlubBlub]] is a named link in org-mode.
As you can see are named-links allowed to include matches for http:://links or CamelCase words which mustn't be processed again. And links can occasionally include CamelCase words.
One approach is to OR the regexes with priority to the more complex ones, such that their matches are only processed once:
s/ ($named|$http|$camel) / tranform() /gxe
Now in the substitution part it's tricky to know which regex matched, thats why I use named captures.
The following code demonstrates what I'm doing!
(please note that for simplicity of the example my only transformation is to return the name of the match.)
I have the impression to reinvent the wheel and fiddling with %- doesn't seem stable...
So please show me easier approaches... :)
( addicted to the Perl Programming Language)