我需要一个正则表达式,它将匹配字符串或文本中的以下单词:
{=rankedArea?metricType=3902&area={parent-area-identifier}:AdministrativeWard}
{=compare?metricType=3281&area={child-area-identifier}&with={parent-area-identifier}&period=cal_2011&greater=greater than&equal=equal to&less=less than}
{district-short-label}
{child-area-short-label}
{authority-area-short-label}
基本上,它应该匹配以"{"开头的单词和以"}"结尾的单词,但是它也应该考虑介于两者之间的类似单词,即
{=compare?metricType=3281&area={child-area-identifier}&with={parent-area-identifier}&period=cal_2011&greater=greater than&equal=equal to&less=less than}
在上面的表达式中,它还应考虑{parent-area-identifier}
,并且应该与上述表达式匹配。
假设你不需要担心{...}
的任意嵌套,你可以这样写:
[{](?:[^{}]+|[{][^{}]*[}])*[}]