开发者

search for string in vi

开发者 https://www.devze.com 2023-03-29 19:05 出处:网络
I want to search for this: SELECT * FROM `influencers` WHERE (author_name = within a log file using vi, I cant figure out how to properly escape this, I have tried:

I want to search for this:

 SELECT * FROM `influencers` WHERE (author_name =

within a log file using vi, I cant figure out how to properly escape this, I have tried:

 SELECT * FROM \`influencers开发者_StackOverflow\` WHERE \(author_name =

And several similar versions, but no luck


In vim, the only character you need to escape is the *:

/SELECT \* FROM `influencers` WHERE (author_name =

If you're using a different vi variant than vim, you'll need to tell us what you're using.


This should work:

SELECT \* FROM `influencers` WHERE [(]author_name =

EDIT: Seeing Keith's answer, he's right. My square brackets are unnecessary. But I'll leave my answer to make a point: whenever I have regex problems, wrapping questionable characters in square brackets is often a quick fix (and doesn't hurt).

0

精彩评论

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