const regex = /("log":".*?(?P<message>Company\s*[^\.]+.)\s*Company:\s*\[(?P<company>[0-9]+)\]\.\s*Rate:\s*\[(?P<rate>[0-9\.B\\\/s]+)\])/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('("log":".*?(?P<message>Company\\s*[^\\.]+.)\\s*Company:\\s*\\[(?P<company>[0-9]+)\\]\\.\\s*Rate:\\s*\\[(?P<rate>[0-9\\.B\\\\\\\/s]+)\\])', 'gm')
const str = `{"kubernetes":{"pod_name":"throttler-0","namespace_name":"default","pod_id":"4f91ad3a-dd6f-4d56-b08a-2225edd67f9b","labels":{"CX_AZ":"us-east-2a","CX_CLOUDFLARE_SITE_ID":"ddb3ffb7b6beb645b97e4bab3fbcfc44","CX_CLUSTER_DNS":"usprod1.us-east-2.k8s-prod.coralogix.us","CX_DEPLOYABLE":"default","CX_DOMAIN":"coralogix.us","CX_ENV_CLASS":"usprod1","CX_ENV_ID":"usprod1","CX_ENV_TYPE":"prod","CX_ORG":"coralogix","CX_PRODUCT":"logs-data","CX_REGION":"us-east-2","CX_REPOSITORY":"throttler","CX_SERVICE_NAME":"throttler","CX_SERVICE_TYPE":"application","app_kubernetes_io_instance":"throttler","app_kubernetes_io_managed-by":"Helm","app_kubernetes_io_name":"throttler","controller-revision-hash":"throttler-8b99fb774","pipelines.coralogix.net\\/managed-by":"eng-pipelines","pipelines.coralogix.net\\/pipelines-version":"0.3.42","statefulset.kubernetes.io\\/pod-name":"throttler-0"},"host":"ip-10-11-108-110.us-east-2.compute.internal","container_name":"throttler","docker_id":"90015d1ac334d32e38f69fa603b22b02a03182d00df7264a006f29b1f4fa066a","container_hash":"529726762838.dkr.ecr.eu-west-1.amazonaws.com\\/throttler@sha256:1f8859d7e841f7f22d24bc882f6677199a747c0b40ee2f2ccb1cc4e10f46d4d3","container_image":"529726762838.dkr.ecr.eu-west-1.amazonaws.com\\/throttler:392e6bdc"},"stream":"stdout","log":"[INFO] 2022-11-03T07:03:02,464 com.coralogix.throttler.model.Violation throttler-0af20f87-e6c8-4b51-8993-9e726245860a-StreamThread-1 Company transitioned into violated state. Company: [2010806]. Rate: [1298828.7833333334B\\/s].","time":"2022-11-03T07:03:02.464514886Z"}`;
const subst = `"message":"$message","company":"$company","rate":"$rate",${1}`;
// 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