Search code examples
c#visual-studio-2010visual-studio

Replace all attributes in Visual Studio


I have many cs files, with attributes such as:

[Js(Md.pr, imo = false, tr="csc")]

where the tr value is changed between each cs file.

I want to delete all these attributes automatically. So I try to use "replace all" in Visual Studio, when I choose regular expressions function. So I wrote:

find what: [Js*]
replace with ''

and it finds many characters in the code, which I don't want to delete.

How can I do it?


Solution

  • I think you're are looking for the following regex:

    \[Js.*\]
    

    The char [ is a special char in regex, so it has to be escaped.

    \[ = [

    . = Matches any single character except a line break.

    * = Matches zero or more occurrences of the preceding expression, and makes all possible matches.

    More information surf to: http://msdn.microsoft.com/en-us/library/2k3te2cs%28v=VS.100%29.aspx