Replace text with JS in a given URL

Asked

Viewed 108 times

0

  • 1

    Just replace? Maybe Function replace help: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace

  • Only with the information you indicate does not work for other numbers, or will it always be just 90 ?. It would be better to give more examples of substitutions you want to do in order to identify a pattern

1 answer

0


You can use the replace

let url = 'https://meusite.com.br/arquivos/ids/785837-90-90/arquivo'

let newUrl = url.replace(/90/g, '160')

console.log(newUrl)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.