Currently I am getting strings that look like this:
I like {{Pizza|Pasta}} for breakfast.
I want to manipulate strings in JS so that they only contain the part after the '|' so that the sentence would be
I like Pasta for breakfast.
So far this piece of code has brought me a fair end.
str.replace(/\{\{.*?\|.*?\}\}/g, "");
But if I have a string like:
I eat {{bread}} and {{cereal|yoghurt}} for breakfast.
The results is:
I eat yoghurt for breakfast.
But I want:
I eat bread and yoghurt for breakfast.
So far I have tried this with regex. But it doesn't seem to replace anything.
str.replace(/\{\{.*((?!]).).*?\|(.*?)\}\}/g, "");