-1

My issue is that on a big application I have to change all the assembly files in each dll, and there is more than a hundred. I would like to use "find and replace" from a text editor to change these two lines :

[assembly: AssemblyProduct("DllsName")] changed to [assembly: AssemblyProduct("s")]

[assembly: AssemblyVersion("1.0")] changed to [assembly: AssemblyVersion("1.xxx")]

where xxx is a fixed number, and DllsName is not the same in every file. I'm a white belt in regular expression but I believe it's the best way to do it : use a regular expression to select just the part I want to change and then replace it. Unfortunately with all those [, ", ( characters I'm not quite sure how to write this expression and I don't know how to change that DllsName because it's not the same in every file. So my question is : Is it possible to change all the files with a regular expression and how ?

Community
  • 1
  • 1
JSFDude
  • 31
  • 4

2 Answers2

1

\[assembly: AssemblyProduct\("[^"]*"\)\] and \[assembly: AssemblyVersion\("1.0"\)\]

How to apply regex replace to multiple files: What's the best tool to find and replace regular expressions over multiple files?

CrafterKolyan
  • 1,042
  • 5
  • 13
1

Using Notepad++, you can search/replace with regular expressions by pressing Ctrl+H and then checking "Regular expression" at the bottom.

To replace every DLL name by "s" : Find: (AssemblyProduct\(")[^"]+("\)) Replace by: \1s\2

To replace all DLL versions to "1.777", Find: (AssemblyVersion\(")1.0("\)) Replace by: \11.777\2

The reason why you are escaping ( is because without escaping, it will just try to create a character group to remember (which then can be reused in the Replace String with \1 or \2 if it is the first or second captured group). " is not a regex command contrary to ( and [ so no need to escape it with \.

I suggested to search [^"]+ (every non " character) instead of .* (all characters) because are regexes greedy and it's always good to know that if you want to reuse the command for other applications.

You can get the detailed ecplanations of any regex expression at https://regex101.com/

Vulpo
  • 873
  • 1
  • 9
  • 25