Eli Schneider
Eli Schneider

Reputation: 4955

Matching double curly braces in Emacs regular expression?

I am creating a simple mode for emacs that finds certain markup tags. One of the things needed is to mark footnotes between double curly braces. {{like this}} I am having trouble having this to working with the regex "\\(\\{[^}]*\\}". I feel like I am very close, but the regex causes many issues. What am I missing for this pattern to work?

Upvotes: 4

Views: 1588

Answers (2)

Stefan
Stefan

Reputation: 61

What are you guys talking about? \{..\} is the repetition operator in Emacs regexps, so if you want to match { and } you don't want to escape them.

E.g. I'd use something like "{{\\([^}]\\|}[^}]\\)*}}".

Upvotes: 6

Stefan
Stefan

Reputation: 14880

This pattern matches one or more chars wrapped in double curly braces:

\{\{[^}]+\}\}

In your pattern the first opening brace was a regular one ( ...

Upvotes: 1

Related Questions