My understanding was that the regexp form a{m,n} would match a at most n times. However, the following snippet does not work as I would expect (this is javascript):
/\{{2,2}/.exec ('df{{{df')
// [ '{{', index: 2, input: 'df{{{df' ]
Shouldn’t it return null?
It is matching the text because there are two. That satisfies the requirements your regex specifies. If you want to prevent extras from matching use a negative lookahead:
(?!\{).Then, use the first captured group.
Edit, by the way, the the
,2in{2,2}is optional in this case, since it’s the same number.Edit: Added usage example to get rid of first matched character. (Javascript doesn’t support negative lookbehind.