Sublime Regex Search and Replace

问题内容:

Trying to use Sublime to update the urls of only some lines in a sql table dump.

in this case the line that I need to single out has the string ‘themo_showcase_\d_image’ which is easy to match. In the same string what I actually need to replace is the url column so that it reads ‘https://www.example.com/‘ to ‘http://www.example.com

Anyone able to help shed some light on this? I’ve got thousands of these insert records that I need to modify.

ex:

original string:

(‘8630’, ‘1328’, ‘themo_showcase_1_image’, ‘https://www.example.com/‘),

to:

(‘8630’, ‘1328’, ‘themo_showcase_1_image’, ‘http://www.example.com/‘),

问题评论:

    
It’s not clear what you want. Can you provide sample inputs and expected outputs?
    
if the string you want to match is always in the tail part of the same URL, something like (http)(://[^<>"']+/themo_showcase_\d_image) could be replaced with $1s$2 (not sure what precise syntax Sublime uses).
    
just updated the question with the original string and expected output after this operation has been correctly. The idea is use the regex to filter out the strings that I don’t want to modify, and then replace the protocol of the url of what’s left.
– Nebri
42 mins ago

答案:

答案1:

  • Find: 'themo_showcase_\d_image', 'http\Ks you could use \d+ if there are more than 1 digit
  • Replace: LEAVE EMPTY

答案评论:

原文地址:

https://stackoverflow.com/questions/47756270/sublime-regex-search-and-replace

添加评论

友情链接:蝴蝶教程