Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
Replace a part of string using replace method

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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Pretty simple.

css.replace(/url\(".+?"\)/, `url("${fonturl}")`)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!