Bug 325361 (MONO82694) - [PATCH] Add subexpression substitution to regex replace
Summary: [PATCH] Add subexpression substitution to regex replace
Status: RESOLVED FIXED
Alias: MONO82694
Product: MonoDevelop
Classification: Mono
Component: texteditor (show other bugs)
Version: SVN
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: MD Bugs
QA Contact: MD Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-04 20:14 UTC by Levi Bard
Modified: 2010-11-11 12:15 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Adds subexpression substitution to regex replace (9.23 KB, patch)
2007-09-04 20:15 UTC, Thomas Wiest
Details | Diff
Updated per comments (7.61 KB, patch)
2007-12-17 18:22 UTC, Levi Bard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:52:02 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".

Comment 1 Lluis Sanchez 2007-10-05 08:04:10 UTC
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.
Comment 2 Levi Bard 2007-12-17 18:22:20 UTC
Created attachment 187927 [details]
Updated per comments
Comment 3 Mike Krueger 2010-11-11 12:15:12 UTC
works with the current implementation.