SyntaxEditor Replace with Regex

SyntaxEditor for Windows Forms Forum

Posted 11 months ago by Frederic Gregoire
Version: 18.1.0340
Avatar

Hello,

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:
      TEXT,INFO,1000

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

I'd expect the output result to be:
    TEXT,TOP,500

But instead, it is:
    $2,500

Is there a way to make this work using the same substitution rules with regex as .net?
https://docs.microsoft.com/en-us/dotnet/standard/base-types/substitutions-in-regular-expressions


Comments (2)

Answer - Posted 11 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I believe your replace pattern should be this instead:

$1,500

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


Actipro Software Support

Posted 11 months ago by Frederic Gregoire
Avatar

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 (v2018.1 build 0341) was released 7 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.