-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 "/"?

MPortman
  • 154
  • 8

1 Answers1

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\//, "/") );
merovingian
  • 515
  • 2
  • 9