Newbie here, but I'm stumped on this grep that I create in BBedit on macOS.
I have some lines in multiple files that have added a file path in error that I'd like to remove.
Here is an example:
BuildFile R:\folder1\folder2\folder3\any_quantity_of_folders\filename.bin
This is what I would like for a result:
BuildFile filename.bin
The file path may have different quantities of \ before it reaches the filename and the drive may be a different letter each time, so I'm look to either remove everything BETWEEN 'BuildFile ' and 'filename.bin' with includes the drive and the path or remove the file path itself.
It doesn't look like BBedit accepts the 'basepath' command (not sure if that's the correct name-sorry).
As an example, I have gotten this to work when the last folder was named _scripting\ in the path, but I cannot find grep code to find the last \ instead as my files don't always have _scripting\ as the last folder. I want to use \ as the last delimiter to make sure I find and fix all the errors.
Search:
^BuildFile (?s).+?_scripting\\
Replace with:
BuildFile
(space is retained after BuildFile text above)
thank you
答案 0 :(得分:0)
以下搜索模式应该这样做(使用现有的替换字符串):
^BuildFile (.*\\)
(.*\\)
匹配以反斜杠结尾的任何字符序列,因此路径最多但不包括文件名。