Regex for matching a C# property getter <p>for code review and problem solving purposes, I'd need to be able to overlook all property getters in a large solution. I'm thinking "<strong>Regex</strong> and <strong>Powershell</strong> to the rescue".</p> <p>I'd need a <strong>rexeg pattern</strong> that matches all getters in a C# file. For example, if this was the test string:</p> <pre><code>public string MockFullName { get { string ns = FullName.Substring(0, FullName.Length - Name.Length - 1); return string.Format("{0}.Mock{1}", ns, Name); } } </code></pre> <p>I'd need the <strong>match</strong> be:</p> <pre><code>get { string ns = FullName.Substring(0, FullName.Length - Name.Length - 1); return string.Format("{0}.Mock{1}", ns, Name); } </code></pre> <p>I've played around in <a href="https://regex101.com/" rel="nofollow noreferrer">https://regex101.com/</a> with pattern...</p> <pre><code>get(.|\n)*{(.|\n)*} </code></pre> <p>...which gives me too much back - includes the closing bracket from class too. </p> <p>Typing this in PowerShell doesn't give anything back for the given C# file:</p> <pre><code>sls 'get(.|\n)*{(.|\n)*}' MyCSharpFileWithAProperty.cs </code></pre> <p>So, what kind of regex pattern would cater for this?</p> <p>Thanks, pom</p> <p>PS: For the record, I'm <strong>not</strong> interested in short form properties, and they can be skipped:</p> <pre><code>public string Name { get; set; } </code></pre>