Regex: replace text with part of the file full path in SublimeText 3

喜欢而已 提交于 2020-01-16 11:52:14

问题


In a "main directory" I have a lot of .txt files, in a lot of subdirectories. Something like

"C:\FirstDir\SecondDir\ MainDir\SomeSubDir_specific_subdirs_\ *.txt"

In each file I want to replace the line:

 reference = someotherfile.ext

with

 reference = MainDir\SomeSubDir\_specific_subdirs_\someotherfile.ext

I've built this expressions:

find:    (reference = )(?!_this_dir_)(.*\.txt)
replace: \1MainDir\\SomeSubDir\\_this_dir_\\\2

but it requires me to open one folder at time and write the folder name "_this_dir_" each time.

There's a way to have (as an internal variable of SublimeText, or from some regex trick) the file directory so i can automate the whole process? (_specific_subdirs_ is the directory of the file i'm editing)

来源:https://stackoverflow.com/questions/58895118/regex-replace-text-with-part-of-the-file-full-path-in-sublimetext-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!