SyntaxEditor Replace with Regex

SyntaxEditor for Windows Forms Forum

Posted 6 years ago by Frederic Gregoire
Version: 18.1.0340


When using the SyntaxEditor, the FindNext and ReplaceNext methods of the "SyntaxEditor.ActiveView.Searcher" take an "IEditorSearchOptions".
These options take a PatternProvider, which, if specified, can handle regex operations. The FindNext handles these scenarios well, but the ReplaceNext only seems to take the ReplacePattern and insert it where a match is found.

For example, given the following text in the syntax editor:

And the following search and replace options:
FindPattern: (TEXT,.*),1000
ReplacePattern: $2,500

I'd expect the output result to be:

But instead, it is:

Is there a way to make this work using the same substitution rules with regex as .net?

Comments (2)

Answer - Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA


I believe your replace pattern should be this instead:


That says use the first captured group.  Does it work how you'd like with that?

Actipro Software Support

Posted 6 years ago by Frederic Gregoire

Should of tried with your prodiver before posting. The issue I was running into was with my custom provider. But I found the solution thanks to your proposal,

Thanks for the help!

The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.