Regex how to match a word without a character in it
How can I match something like {anyWord}
but exclude anything that has an underscore at the beginning, like this: {_doNotMatchThis}
?
Input:
hi there {matchPlease}{andThis}, just doing some regex {_notThis}
Desired matches:
{matchPlease}
{andThis}
Without that condition of excluding the starting {_
, I know that this regex pattern works well: {w+}
I've tried to modify that to be, {!_w+}
, basically saying, "match anything that starts with {
, then has a word that does not start with _
, then ends in }
". Thanks.
How about this?
/{([^_].*?)}/
And per @Geo and @nhahtdh in the comments, if you want only words:
/{([^_]w*)}/
链接地址: http://www.djcxy.com/p/77012.html
上一篇: 匹配任何重复n次的序列
下一篇: 正则表达式如何匹配没有字符的单词