sábado, 2 de junio de 2012

Find and Replace with a Break Line - Regular Expresions

I had a hard time trying to replace :



with




I had to replace it nearly 1200 times!!!!, then I found a SEXY way to do it  USING
THE FIND AND REPLACE WINDOWS AND REGULAR EXPRESIONS:
I manage to do that with this:

find       : e\)\n:b^12\{ 
replace : e\)\n            \{\n                Log(e);


Explanation:
Find Pattern:  'e' follow  ')'             note:  ')'  is a special character in regular expresion then if you want to include it in your pattern you have to put escape caracter before '\'.
\n indicates break line | new line.
:b indicates a white space, then   ^12 indicates repetitions. :b^12 indicates 12 white spaces.
\{   escape character follow {.

Replace pattern:
The only change is that the 12th white spaces must be changed by explicit twelve white spaces.


Another Example: Add [Serialize] to a Class

namespace Entities\n\{

namespace Entities\n\{\n[Serializable]










1 comentario: