Bugzilla – Bug 325361
[PATCH] Add subexpression substitution to regex replace
Last modified: 2010-11-11 12:15:12 UTC
---- Reported by taktaktaktaktaktaktaktaktaktak@gmail.com 2007-09-04 13:14:26 MST ---- Adds subexpression substitution to regex replacement. E.g., one can now replace in(put) with out$1 ---- Additional Comments From taktaktaktaktaktaktaktaktaktak@gmail.com 2007-09-04 13:15:10 MST ---- Created an attachment (id=172610) Adds subexpression substitution to regex replace Imported an attachment (id=172610) Unknown operating system unknown. Setting to default OS "Other".
I think the patch needs some improvements. It introduces a text transform in DefaultFind.Replace, but in SearchReplaceManager.cs there is: string transformedPattern = result.TransformReplacePattern(SearchOptions.ReplacePattern); find.Replace (result, transformedPattern); which means that the result is being transformed twice. It should be clear if the transform is always executed by DefaultFind.Replace or it must be done before calling that method. Also, there is no need to define a new TransformReplacePattern(Regex,string) method in RegExSearchResult. ISearchResult.TransformReplacePattern can do the transform (just keep a reference to RegExSearchStrategy in RegExSearchResult, TransformReplacePattern can then get the regex from it). In this way you can remove the type checks from DefaultFind.Replace, and the code is more generic.
Created attachment 187927 [details] Updated per comments
works with the current implementation.