开发者

Confusing regex behavior when combining ` with (

In order to work around a mysql 5.0 to 5.1 compatibility issue, I'm trying to change this pattern:

KEY `brand_id` (`brand_id`) USING开发者_Go百科 BTREE

to this:

KEY `brand_id` USING BTREE (`brand_id`)

Running the following regex in vim locates all the occurrences of the issue:

KEY `.*` \(.*\) USING BTREE

So, I tried just modifying this to the following substitution string, but it can no longer locate the matching strings. Why?

%s/KEY (`.*`) (\(.*\)) USING BTREE/KEY \1 USING BTREE (\2)/gc


I don't know why, but in Vim you need to escape the matching parentheses and leave them alone when they are to be taken literally. Try:

%s/KEY \(`.*`\) \((.*)\) USING BTREE/KEY \1 USING BTREE \2/gc
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜