@@ -878,6 +878,13 @@ public static ExecutorSingleOperationResp modifySampleDataUtil(String operationT
878
878
String regex = regexInfo .get ("regex" );
879
879
String replaceWith = regexInfo .get ("replace_with" );
880
880
newPayload = Utils .applyRegexModifier (payload , regex , replaceWith );
881
+ } else if (key instanceof String && key != "" && ((String ) key ).contains ("regex_replace" )) {
882
+ Map <String , Map <String , String >> regexReplace = parseStringToMap ((String ) key );
883
+ String payload = rawApi .getRequest ().getBody ();
884
+ Map <String , String > regexInfo = regexReplace .get ("regex_replace" );
885
+ String regex = regexInfo .get ("regex" );
886
+ String replaceWith = regexInfo .get ("replace_with" );
887
+ newPayload = Utils .applyRegexModifier (payload , regex , replaceWith );
881
888
} else {
882
889
newPayload = key .toString ();
883
890
}
@@ -938,5 +945,34 @@ public static ExecutorSingleOperationResp modifySampleDataUtil(String operationT
938
945
939
946
}
940
947
948
+ public static Map <String , Map <String , String >> parseStringToMap (String mapString ) {
949
+
950
+ mapString = mapString .trim ();
951
+ if (mapString .startsWith ("{" ) && mapString .endsWith ("}" )) {
952
+ mapString = mapString .substring (1 , mapString .length () - 1 );
953
+ }
954
+
955
+ Map <String , Map <String , String >> resultMap = new HashMap <>();
956
+ String [] entries = mapString .split ("=" , 2 );
957
+
958
+ String outerKey = entries [0 ].trim ();
959
+ String innerMapString = entries [1 ].trim ();
960
+
961
+ innerMapString = innerMapString .substring (1 , innerMapString .length () - 1 );
962
+
963
+ Map <String , String > innerMap = new HashMap <>();
964
+ String [] innerEntries = innerMapString .split (", " );
965
+
966
+ for (String innerEntry : innerEntries ) {
967
+ String [] innerKeyValue = innerEntry .split ("=" , 2 );
968
+ String innerKey = innerKeyValue [0 ].trim ();
969
+ String innerValue = innerKeyValue [1 ].trim ();
970
+ innerMap .put (innerKey , innerValue );
971
+ }
972
+
973
+ resultMap .put (outerKey , innerMap );
974
+ return resultMap ;
975
+ }
976
+
941
977
942
978
}
0 commit comments