My regex skills are pretty poor, and most of the time they make me feel stupid. Can anyone help?
This question is more concerned with better mastery of regex than the job of extracting information from mud soup, so if my understanding of the mediawiki template system is flawed, I don't really mind that much. I'll spot it soon enough.
I'm parsing MediaWiki markup, and I'm trying to grab MediaWiki template names. These denoted by something like:
{{Template Name|other stuff
or
{{Template Name}}
If a # immediately follows the braces :
{{#Other thing
I'd like to ignore it.
So...
I'd like to match 2 curly braces {{ not followed by # up until the next occurrence of either | (pipe) or }} (2 closing curlies)
So:
{{I am a frog|some other stuff match
{{#I am a frog|some other stuff fail
garbage here{{Monkey}}bla bla match
garbage here{{#Monkey}}bla bla fail
etc...
The following regex covers this (I think):
\{{2}(?!\#)(.*?)(?:\||\}\})
but also matches:
some stuff here {{{Giraffe|oijq
How can I make it fail if there are not exactly 2 opening curly braces?
EDIT: .net regex, btw