const regex = /\s(\w*)Command\.Register\((([\S]*,([^;\n\r])*)+)typeof\((.*)Values\)\);/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\s(\\w*)Command\\.Register\\((([\\S]*,([^;\\n\\r])*)+)typeof\\((.*)Values\\)\\);', 'g')
const str = `public static readonly SimpleCommand ReadTemperatureCommand =
SimpleCommand.Register(ReadTemperatureCommandId, "ReadTemperature", "showtemp.py", "", 5, typeof(TemperatureListCommandResultProcessor), typeof(TemperatureListDeviceValues));
public static readonly SimpleCommand GetDataType1Command =
SimpleCommand.Register(
GetDataType1CommandTypeId,
"GetData",
"HttpClient2.py",
@"""/data/ajax.txt?CAN=1&HASH=00200403&TYPE=1"" ""GET"" """"",
5,
typeof(SunwaysSolarInverterDataType1CommandResultProcessor),
typeof(SunwaysSolarInverterDeviceValues));
public static readonly ArgumentedCommand UpdateAsyncCommandsCommand =
ArgumentedCommand.Register(
UpdateAsyncCommandsCommandId,
"UpdateAsyncCommands",
"UpdateAsyncCommands.py",
"",
5,
UpdateAsyncCommandsCreateArguments,
new[] { typeof(AsynchronousCommand[]) },
typeof(UpdateAsyncCommandsCommandResultProcessor),
typeof(GridboxCommunicationObjectValues));
public static readonly SimpleDynamicObjectAttribute<bool> AsynchronousCommandsChangedProperty =
SimpleDynamicObjectAttribute<bool>.Register("AsynchronousCommandsChanged", false, typeof(BusyGridObjectValues), false, false);
public static readonly SimpleDynamicObjectAttribute<string> MailProperty =
SimpleDynamicObjectAttribute<string>.Register("Mail", typeof(DefaultUserValues));
public static readonly ProtectedSimpleDynamicObjectAttribute<int> PasswordStorageMethodVersionProperty =
ProtectedSimpleDynamicObjectAttribute<int>.Register("PasswordStorageMethodVersion", 2, typeof(DefaultUserValues));
public static readonly ListSetDynamicObjectAttribute<string> LocalIpNetworksProperty =
ListSetDynamicObjectAttribute<string>.Register("LocalIpNetworks", typeof(GridboxCommunicationObjectValues));
public static readonly DictionaryDynamicObjectAttribute<Guid, GridObjectTypeContentFilter> ContentFiltersProperty =
DictionaryDynamicObjectAttribute<Guid, GridObjectTypeContentFilter>.Register("ContentFilters", typeof(DefaultContentFilterValues));
public static readonly StrongGridObjectReference ContentFilterListContentFilterIdProperty =
StrongGridObjectReference.Register("ContentFilterListContentFilterId", new Guid("ce06d088-1b5e-4cab-98d2-b0fd63bc0d5b"), typeof(ContentFilterValues));
public static readonly GridObjectReference ContentFilterListContentFilterIdProperty =
GridObjectReference.Register("ContentFilterListContentFilterId", new Guid("ce06d088-1b5e-4cab-98d2-b0fd63bc0d5b"), typeof(ContentFilterValues));
public static readonly GridObjectReference ContentFilterListContentFilterIdProperty =
GridObjectReference.Register("ContentFilterListContentFilterId", new Guid("ce06d088-1b5e-4cab-98d2-b0fd63bc0d5b"), typeof(ContentFilterValues));
public static readonly GridObjectReferenceList PermissionIdsProperty =
GridObjectReferenceList.Register("PermissionIds", typeof(DefaultRoleValues));`;
const subst = `GridObjectModel.Register$1Reference$2($3, $4TypeIdString);`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions