hnakamur / FormatLink-Firefox

A Firefox web-extension to copy the URL and the title or the selected text to clipboard
https://addons.mozilla.org/ja/firefox/addon/format-link3/
MIT License
45 stars 8 forks source link

trouble replacing zero-width chars #56

Closed atomGit closed 1 year ago

atomGit commented 1 year ago

i want to remove zero-width characters, however this is not working

Title             Format 
test              {{text}}

Variable          Format
text              {{text.s("[^[:print:]*","")}}

this string contains zero-width chars: this‌‌‌that when i copy it, this is the result: titt

hnakamur commented 1 year ago

.s("[^[:print:]*","") deletes any character except [, :, p, r, i , n, t since Regexp in JavaScript does not support POSIX character class like :print:

{{text.s("[\\u200B]","")}} can be used instead to remove zero-width characters.

atomGit commented 1 year ago

thanks!

after some fooling around i came up with this which i think will accomplish what i want... .s("[\\u200B-\\u200D\\uFEFF]","")