i just want to know the replace function in js to convert the below text to another.
@font-face {
font-family: "Alloy Ink";
font-style: normal;
font-display: swap;
src: url("alloy-ink.otf") format("opentype");
}
it is stored as a string in variable data. In this src needs to be replaced and it should look like:
@font-face {
font-family: "Alloy Ink";
font-style: normal;
font-display: swap;
src: url("https://cdn.jsdelivr.net/npm/@creative-fonts/alloy-ink/alloy-ink.otf")
format("opentype");
}
Also https://cdn.jsdelivr.net/npm/@creative-fonts/alloy-ink/alloy-ink.otf is stored in a variable named fonturl.
>Solution :
Pretty simple.
css.replace(/url\(".+?"\)/, `url("${fonturl}")`)