hnakamur / FormatLink-Chrome

Format a link and title of the active tab of Chrome and MS Edge and copy it the clipboard
https://chrome.google.com/webstore/detail/format-link/pocemhmkmchpgamlnocemnbhlcjcbjgg?hl=ja
MIT License
11 stars 2 forks source link

Regex replace to remove a string. #10

Closed cecoates closed 4 years ago

cecoates commented 5 years ago

I'm trying to use the regex replace feature, but running into trouble trying to remove parts of the URL. Such as removing HTTP, HTTPS, and www.

However, it doesn't seem to work if you try and use an empty string as the replacement.

For example:

{{url.s("\^(?:https?:\/\/)?(?:www\.)?","")}}

Does not work.

Neither does:

{{url.s("\^(?:https?:\/\/)?(?:www\.)?","\^$")}}

or

{{url.s("\^(?:https?:\/\/)?(?:www\.)?","^$")}}

The closest option is to use a single space, like this:

{{url.s("\^(?:https?:\/\/)?(?:www\.)?"," ")}}

Is it not possible to delete part of the URL/text?

The extension is very handy so far, thanks!