I'm new to regx and in visual studio 2010 I want to find
</local>
<local>
<some words>
</local>
and replace it with
</local>
I can find first line by
/[local]+[>][\n]
but I don't know what should I do to find whole expression.Please help me.
I am assuming that you want to remove anything after </local>
So, just do (?s)(?<=</local>).*?</localizedCaptions>
and replace with an empty string. (?s) is SingleLine modifier.
If (?s) isn't working, then just do (?<=</local>)[\s\S]*?</localizedCaptions>
Related
In windows 2008, we have multiple files in a directory. The files are having paths as contents and those texts should be replaced with other string.Find example below:
The files are having the paths like:
File1:
C:\Apps\ etc\A1\X.exe should be replaced with C:\Apps\ exe\X.exe
File2:
C:\Apps\ etc\B1\Y.exe should be replaced with C:\Apps\ exe\Y.exe
I am trying to find a single command which will replace the bold lettered strings as mentioned above.
In case of normal strings I use the below command and it works:
perl -i.bak -pe "BEGIN{#ARGV = map glob, #ARGV} s/string1/string2/g" ./*.txt
But the current requirement seems to use regular expression for which I am not able to find a solution.
Just replace etc\ followed by anything up to a \ again with just exe:
's/etc\\[^\\]*\\/exe\\/g'
I have to add some javascript code in VS 2013.
Before (Now)
Layout.init();
After (What I want)
Layout.init();
Side.init();
If there were no () I could do it with \n but VS do not find them.
How can I change them like latter?
edit:
I want to change all my project in every page with ctrl+H;
I can change with ctrl+H and regex enabled:;
find:
abc
replace:
abc
def
with this regex
replace:
abc \n def
when I try to change with () VS don't find any of them...
I'd suggest using Notepad++ > 'Find in Files' option to replace text in bulk. It works for files inside a specific directory or if needed, can traverse all sub-directories and replace them. See the below snapshot for settings needed
I recommend you free Multiline Search and Replace Visual Studio extension. It supports Find/Replace in files.
I have a conf file that is loading plugins. I need to parse and match a certain plugin in a directory but not others in the same directory:
plugin: c:\program files\application\abc\abc.dll
plugin: c:\program files\application\abc\xyz.dll
I need to match the abc.dll only but due to the fact that the abc is also in the dir name, it matches both lines but I dont want xyz.dll
So I tried:
^plugin:(.*)(abc.dll)
So ^ = start of line, then plugin, then .* anything, then abc escape dot dll.
But it doesnt seem to work. Can anyone help please?
The problem is the dot in abc.dll. Try escaping it so it's not a wild card.
^plugin:(.*)(abc\.dll)
You would like to use this regexp:
([a-zA-Z0-9-_]*\.dll)
Here is example
What is a regular expression I can use in Vim to find conflicts in CVS and possibly other version control systems?
Here is a regular expression to find entire conflict sections:
[<]\{7}.*\_.\{-}[=]\{7}\_.\{-}[>]\{7}.*
And to search for that in vim, just press the '/' key and paste that regular-expression string, then press enter.
Usually CVS conflicts look like this:
<<<<<<< file.c
Code from file.c
=======
Code from the repository version 1.2
>>>>>>> 1.2
Vim search-and-replace command to keep local version:
:%s/[<]\{7}.*\n\(\_.\{-}\)[=]\{7}\_.\{-}[>]\{7}.*\n/\1/g
Vim search-and-replace command to keep repository version:
:%s/[<]\{7}.*\_.\{-}[=]\{7}\n\(\_.\{-}\)[>]\{7}.*\n/\1/g
I usually just do /<<< and press 'n' until I find no more matches. It is a much less sophisticated approach than Neil's, but it works for me :)
I'm trying to use TextPad to search for a regular expression in several files. I have a simple pattern but it doesn't work in TextPad. It works fine in Visual Studio.
Anyone have any ideas?
I'm searching for:
hosted.mysite.com or host.mysite.com
using the pattern:
(hosted|host)\.mysite\.com
Use something like this
\(hosted\|host\).mysite.com
try this:
host\(ed\)?\.mysite\.com
Not every text editor uses the same regex/conventions. A regex you may get to work in Visual Studio won't necessarily work in Eclipse, Netbeans, or some other IDE or text editor.
In Textpad you need to escape some characters, such as parenthesis and pipes.
In your case, what you need is this:
\(hosted\|host\)\.mysite\.com
Note: you need to escape dots as well.
Textpad's POSIX regexes are good, but even better results could be achieved by installing the Win GNU util grep and adding a cmd /c "Prompt for parameters " , "Capture output" command: thus you could have full Find in files with even Perl regexes:
grep -nhPr "CoolRegexToSearchWith" C:\MyDir\ToSearchRecursivly