-1

I'm looking to make a script that edits a url.

This currently works

jQuery(".int-tooltip a").attr("href", (_, href) =>
href.replace("/zh-hant/", "/") );

But how do I add multiple options besides "/zh-hant/"? Such as "/de/" or others to check and replace them with "/"?

1
  • What is the structure of your URL? Commented Dec 12, 2022 at 20:06

1 Answer 1

3

To add multiple options to the replace method, you can use a regular expression with the | character, which represents a logical OR.

jQuery(".int-tooltip a").attr("href", (_, href) =>
href.replace(/\/zh-hant\/|\/de\/|\/other-option\//, "/") );
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.