node-projects / web-component-designer

A Designer for HTML Components or Pages in a WebComponent
https://node-projects.github.io/web-component-designer-demo/index.html
MIT License
150 stars 16 forks source link

Add advanced regex replace for code editor #243

Open 7evenk opened 1 year ago

7evenk commented 1 year ago

It should be possible to define a callback function in the replace field.

image

So it is possible to do math operations during replacement.

const regex = /(grid-row:)([0-9]*)/g;
let replacedText = text.replaceAll(regex, (match, g1, g2) => {
    let result = parseInt(g2) + 1;
    return g1 + result;
});