开发者

Vim/Perl Regex Tag Match Problem

I have data that looks like this:

[Shift]);[Ctrl][Ctrl+S][Left mouse-click][Backspace][Ctrl]

I want to find all [.*] tags that have the word mouse in them. Keeping in mind non-greedy specifiers, I tried this in Vim: \[.\{-}mouse.\{-}\], but this yielded this result,

[Shift]);[Ctrl][Ctrl+S][Left mouse-click]开发者_如何学Go

Rather than just the desired,

[Left mouse-click]

Any ideas? Ultimately I need this pattern in Perl syntax as well, so if anyone has a solution in Perl that would also be appreciated.


\[[^]]*mouse[^[]*\]

That is, match a literal opening bracket, then any number of characters that aren't closing brackets, then "mouse," then any number of non-opening-brackets, and finally a literal closing bracket. Should be the same in Perl.


You can use the following regex:

\[[^\]]*mouse.*?\]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜