Find and Replace brackets () with new Line in Visual Studio - regex

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.

Related

Geany "Find in files" breaks when brackets included in search string

I have Geany 1.27 installed in my UbuntuĀ 14.04 (Trusty Tahr). But I also have Windows 7 OS with Geany 1.28 installed.
In both these versions of Geany, when I try to find a string into a multiple files or folder with file-type filter of "phtml" or "php", I see that when my search string includes ( or ) (for example, function new() the search fails.
Now I have a slight idea that this could be due to un-escaped bracket in string acting as part of Regex in grep command. Am I right?
How can I overcome the unescaped characters in search string when searching in Geany? In both Ubuntu and Windows Geany if the method could be different.
Ensure you properly escape your braces, as depending on options, you have set the regular expression is used for searching.
Your function search would be something like new\(\). The documentation is more detailed.

Text replacement in all the files in a directory

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'

find and replace with regular expression in visual studio

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>

Regular expression search and replace in multiple files (bulk) - without opening files

I normally use Notepad++ to search and replace what I need (regex), however, I have to open all the files that I need, in order to replace what is needed to be replaced.. My question is how can I do that in bulk (multiple) files, in a folder, without opening any of the files? Is there a good freeware to do that with? or something like creating .bat or .pl file, and run it in the folder to execute the replace? If so, how can it be done?
Simple example:
<b>(\d+\. )</b>
to
\1
This regex removes the bold tag in numbers.
How can it be done for bulk files without using NP++ under Windows?
Use Notepad++'s own Find in files function, that you can find in the Find menu.
This can be done with this perl oneliner:
perl -pi.back -e 's#<b>(\d+\.\d+)</b>#$1#g;' file*
This will process all files that have their name beginning with file and save them before into fileX.back.

Regex pattern search in TextPad fails, works in Visual Studio

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