const regex = /(.*)\nNegative prompt: (.*)\nSteps: (\d+), Sampler:(.*), CFG scale: (\d+), Seed: (\d+), Size: (.*), Model hash: (.*), Model:(.*), Denoising strength: (.*), Eta: (.*), First pass size: (.*)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(.*)\\nNegative prompt: (.*)\\nSteps: (\\d+), Sampler:(.*), CFG scale: (\\d+), Seed: (\\d+), Size: (.*), Model hash: (.*), Model:(.*), Denoising strength: (.*), Eta: (.*), First pass size: (.*)', 'g')
const str = `professional [digital airbrush:photo:0.5] art of an imp with sword, wearing old cloak, curly pale red-blonde hair, with few tattoos, dynamic bright atmospheric lighting
Negative prompt: logo, text, signature, (bad art)
Steps: 75, Sampler: DPM++ 2M Karras, CFG scale: 12, Seed: 3334373882, Size: 768x1152, Model hash: 81761151, Model: Stable1.5, Denoising strength: 0.7, Eta: 0.89, First pass size: 0x0`;
const subst = `Prompt|$1\nNegative prompt|$2\nSteps|$3\nSampler|$4\nCFG scale|$5\nSeed|$6\nSize|$7\nModel hash|$8\nModel|$9\nDenoising strength|$10\nEta|$11\nFirst pass size|$12`;
// 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