tags:

views:

47

answers:

2

It also needs to work for {{ article |image}} or any other withespace combination inside the double braces.

+1  A: 

This will match all your {{ }} content:

{{([^}]*)}}
Rubens Farias
{} are not metacharacters except when used as the {min,max} quantifier, so no need to escape them, especially not in the character class.
Paul Creasey
nice tip, Paul, ty
Rubens Farias
+1  A: 

Need a lot more information about exactly what you need and the type of data you are searching.

{{.*}}

This will work for both examples.

{{\s*\w+\s*\|\s*\w+\s*}}

Is much more specific.

Paul Creasey
`{{.*}}` will match this entire string: `{{abc}} nono {{def}}`; you should to use a non-greedy pattern, as `{{.*?}}`
Rubens Farias
thanks, this works. what should I replace in this regex to make in work for only {{article | image}} and not for {{article | something_else}}.
`{{\s*article\s*\|\s*image\s*}}` will do the trick; sad use for a regex
Rubens Farias