@@ -45,6 +45,8 @@ public partial class RegExToolDialog : Window
45
45
46
46
private bool mustSelectEditor = false ;
47
47
48
+ private Regex cSharpReplacePartSplitter = new Regex ( "#global(?<global>.*)#endglobal" , RegexOptions . Compiled ) ;
49
+
48
50
private BracketColorizer currentBracketColorizer = new BracketColorizer ( ) ;
49
51
private BracketColorizer matchingBracketColorizer = new BracketColorizer ( ) ;
50
52
@@ -548,7 +550,10 @@ private void ReplaceAllButton_Click(object sender, RoutedEventArgs e)
548
550
549
551
if ( CSharpReplaceCheckbox . IsChecked . GetValueOrDefault ( ) )
550
552
{
551
- dynamic script = CSScript . Evaluator . LoadCode ( Res . CSharpReplaceContainer . Replace ( "//code" , ReplaceEditor . Text ) ) ;
553
+ dynamic script = CSScript . Evaluator . LoadCode (
554
+ Res . CSharpReplaceContainer
555
+ . Replace ( "//code" , cSharpReplacePartSplitter . Replace ( ReplaceEditor . Text , string . Empty ) )
556
+ . Replace ( "//global" , cSharpReplacePartSplitter . Match ( ReplaceEditor . Text ) . Groups [ "global" ] . Value ) ) ;
552
557
553
558
int index = - 1 ;
554
559
@@ -753,9 +758,14 @@ private void ExtractMatchesButton_Click(object sender, RoutedEventArgs e)
753
758
dynamic script = null ;
754
759
755
760
if ( CSharpReplaceCheckbox . IsChecked . GetValueOrDefault ( ) )
756
- script = CSScript . Evaluator . LoadCode ( Res . CSharpReplaceContainer . Replace ( "//code" , ReplaceEditor . Text ) ) ;
761
+ {
762
+ script = CSScript . Evaluator . LoadCode (
763
+ Res . CSharpReplaceContainer
764
+ . Replace ( "//code" , cSharpReplacePartSplitter . Replace ( ReplaceEditor . Text , string . Empty ) )
765
+ . Replace ( "//global" , cSharpReplacePartSplitter . Match ( ReplaceEditor . Text ) . Groups [ "global" ] . Value ) ) ;
766
+ }
757
767
758
- void Extract ( string text , string fileName = "" )
768
+ void Extract ( string text , string fileName = "" )
759
769
{
760
770
List < Match > matches = regex . Matches ( text )
761
771
. Cast < Match > ( )
@@ -1386,7 +1396,10 @@ private void ReplaceInEditor_MenuItem_Click(object sender, RoutedEventArgs e)
1386
1396
1387
1397
if ( CSharpReplaceCheckbox . IsChecked . GetValueOrDefault ( ) )
1388
1398
{
1389
- dynamic script = CSScript . Evaluator . LoadCode ( Res . CSharpReplaceContainer . Replace ( "//code" , ReplaceEditor . Text ) ) ;
1399
+ dynamic script = CSScript . Evaluator . LoadCode (
1400
+ Res . CSharpReplaceContainer
1401
+ . Replace ( "//code" , cSharpReplacePartSplitter . Replace ( ReplaceEditor . Text , string . Empty ) )
1402
+ . Replace ( "//global" , cSharpReplacePartSplitter . Match ( ReplaceEditor . Text ) . Groups [ "global" ] . Value ) ) ;
1390
1403
1391
1404
int index = - 1 ;
1392
1405
@@ -1431,7 +1444,10 @@ private void ReplaceInEditor_MenuItem_Click(object sender, RoutedEventArgs e)
1431
1444
1432
1445
if ( CSharpReplaceCheckbox . IsChecked . GetValueOrDefault ( ) )
1433
1446
{
1434
- dynamic script = CSScript . Evaluator . LoadCode ( Res . CSharpReplaceContainer . Replace ( "//code" , ReplaceEditor . Text ) ) ;
1447
+ dynamic script = CSScript . Evaluator . LoadCode (
1448
+ Res . CSharpReplaceContainer
1449
+ . Replace ( "//code" , cSharpReplacePartSplitter . Replace ( ReplaceEditor . Text , string . Empty ) )
1450
+ . Replace ( "//global" , cSharpReplacePartSplitter . Match ( ReplaceEditor . Text ) . Groups [ "global" ] . Value ) ) ;
1435
1451
1436
1452
if ( regexResult is RegexMatchResult regexMatchResult )
1437
1453
newText = beforeMatch + script . Replace ( ( Match ) regexMatchResult . RegexElement , regexMatchResult . RegexElementNb , regexResult . FileName , regexMatchResult . RegexElementNb , 0 ) + afterMatch ;
0 commit comments