regex - Parsing wiki templates calls with Javascript -


I want to split the wiki template call for the parameter parts. In a very basic scenario, this is | is simply broken by {{template | Unnamed_parameter | Param1 = value1}} will be divided into {{template , unnamed_parameter , param1 = value1 and }} .

But things are complicated when the pipe is used for the character other purposes such as Wikilein [[link | Title]] etc.

Any suggestions how to do this work in a simple way? :)

Update: Sorry for possibly misunderstanding but {{template | Unnamed_parameter | Param1 = value1}} is an example. For more information about wiki templates, you can see the following resources:

Please enter this Q & A See

My answer is parsing a very similar wiki link using perl regex (in the update section).

Update:

OK, for your case, Pearl Reggae is here:

  echo "{{template | unnamed_parameter | param1 = value1} } "| \ Perl -pe 's # (^ | \ b) ((?! [| \ []) {{(. +?) \ | (. +?) \ | (. +?)}} (?! [ ($ | \ B) # {{$ 3, $ 4, $ 5 and}} #g 'output: {{template, anonymous_permator, absolute 1 = value1 and}}   

Q: Are you sure that before and to close }} otherwise just edit it above regex:

And now check the solution against the string [[link | title]]

  resonance "[[link | title]]". Perl - Pe's # (^ | \ b) ((?! [| \ []) {{(. +?) \ | (. +?) \ | (. +?)}} (?! [# $ { $ 3, $ 4, $ 5, and}} #G 'output: [[link | title]] #th Remains unchanged in accordance with the requirements    

Comments