I’ve got an old wiki that I’m converting to a new wiki which uses Markdown and [[]] wiki link format. Unfortunately, the old wiki is really old and had many ways of producing links, incl. CamelCase, single-bracket ([]) wiki links, among others.
I’m converting w/regular expressions in sed and use the following regular expression to convert stand-alone CamelCase links to double-bracket ([[]]) wiki links:
s/([^[|])([A-Z][a-z]+[A-Z][A-Za-z]+)([^]|])/\1\[\[\2\]\]\3/g
Unfortunately, the one problem with the above (in my attempt to not convert CamelCase in existing single-bracket wiki links, since there’s a mix of both) is that something like [BluetoothConnection|UsingBluetoothIndex] will get converted to [BluetoothConnection|Using[[BluetoothInde]]x].
How can I resolve this issue and force the match to be more greedy and therefore fail and not make a substitution in that case? If sed‘s enhanced regular expressions turn out to be too limiting, I’m willing to pass through perl instead of sed.
Alright can you try this:
Update:
Alright I believe now I have regex for your problem using perl’s negative look behind directive. So here it is:
All it is doing is checking if text is not starting with ‘|’ or ‘[‘ and NOT ending with
|or]then enclose it in[[and]].