BBEdit Search and Replace a slash (/) with a Backslash ( - search

I have a question regarding BBEdit (Search & Replace). In a XML I would like to replace the / (slash) with a \ (back slash) and to replace "/Volumes/Server/" to "C:" but only want to replace it in lines that have the word <FilePath> in it.
Here how it should look like.
BEFORE
<FilePath>/Volumes/Server/02_Media/Block_1522/01_Ingest/SD 120722/Teil 3/Kam A/A846C014_130101_R4YJ_Proxy.mov</FilePath>
AFTER
<FilePath>C:\02_Media\Block_1522\01_Ingest\SD 120722\Teil 3\Kam A\A846C014_130101_R4YJ_Proxy.mov</FilePath>
It's important that it doesn't replace the / (slash) in </FilePath> as this must stay the same.
I would be so happy if somebody could help me as I'm trying since a long time.
Thank you very much!
Best,
Tim

Related

Find and replace '\' in vim [duplicate]

For instance, if I wanted to a find and replace with strings containing backward or forward slashes, how would this be accomplished in vim?
Examples
Find & Replace is: :%s/foo/bar/g
what if I wanted to find all occurrences of <dog/> and replace it with <cat\>
Same way you escape characters most anywhere else in linuxy programs, with a backslash:
:%s/<dog\/>/<cat\\>
But note that you can select a different delimiter instead:
:%s#<doc/>#<cat\\>#
This saves you all typing all those time-consuming, confusing backslashes in patterns with a ton of slashes.
From the documentation:
Instead of the / which surrounds the pattern and replacement string, you
can use any other single-byte character, but not an alphanumeric character,
\, " or |. This is useful if you want to include a / in the search
pattern or replacement string.
%s:<dog/>:<cat>
You can replace the / delimiters if they become annoying for certain patterns.
Quote them with a backslash. Also, it often helps to use another delimiter besides slash.
:%s#<dog/>#<cat\\>#
or if you have to use slash as the substitute command delimiter
:%s/<dog\/>/<cat\\>/
I was looking for something similar, to search for register values containing the / character (to record a macro). The solution was to search using the ? token instead of the /.
The syntax is:
:%s/<dog\/>/<cat\\>/g
backslash slash backslash star
/(<- the prompt)\/\*
so after you type it looks like
/\/\*

Need regex to search string containing '+'

i need to search a string containing + like 'abc+xyz' or 'test+1234',
currently I am using 'abc.*' but not able to search 'abc+xyz'
Basic regex docs will explain that you can reference a special character by escaping it. The following pattern matches on abc+xyz.
abc\+xyz
A tutorial explaining the above.
for finding regex which contains special character like above situation, just add "\" (back slash)

I want to Replace a word which contains more no of / using vim

I want to replace this word /BGL/HUG/LIK/ to /TOM/GUY/MAP/ using vim editor I have tried %s/ commands it's not working please give some better solutions.
You can replace the separator / after %s with any character, so you can choose one that is not included in your source text, e.g.
%s,/BGL/HUG/LIK/,/TOM/GUY/MAP/,g
Hope this helps.

Vim replace with '/' and numbers

Vim replace is very hardy to use when I haven't came across problems like this:
1) replace numbers with other text
2) replace text like /static/ to www.website.com/
I assume I need to use some regex to tackle the first problem and some way to get around the / mark for the second.
Any quick solutions ?
Thanks!
:%s/\d\+/sometext/g
:%s/\/static\//www.website.com\//g

Trouble searching in VIM with file having lots of slashes and dots

I've got a bunch of really big files that contain lines like:
convert ./1776/07/04/T915002.tif ./1776/07/04/T915002.png
rm ./1776/07/04/T915002.tif
convert ./1776/07/04/T918012.tif ./1776/07/04/T918012.png
rm ./1776/07/04/T918012.tif
What I want to do is search for say /1861/ meaning a line for the year 1861
But vim seems to interpret that 'go to line 1861, which is not at all what I want.
Searching for the ./1861/ fails too. I assume the leading dot tried to match any character. Trying to backslash quote it fails too. Clearly I'm missing a fundamental idea or two.
Thanks
You need a backslash to escape the dot or the slash:
/\.\/1861\/
Use ? to search backwards. This means you don't need to escape the /s.
?/1861/

Resources