Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Conversation

@tibor
Copy link
Contributor

@tibor tibor commented Nov 9, 2024

added functionality for domains and mails

added functionality for domains and mails
@tibor
Copy link
Contributor Author

tibor commented Nov 9, 2024

#31

@marcomaroni-github
Copy link
Owner

@tibor Could you give me some examples of substitution that are not clear to me when reading the regular expression?

@tibor
Copy link
Contributor Author

tibor commented Nov 9, 2024

Sorry!
(@)[^\s]+.\w+

(@) = the capturing group, i.e. what we want to replace
[^\s]+ = next to the @ has to be a / multiple character that is not a whitespace (i.e. no space, no linebreak etc.)
. = literally a dot
\w+ = a / multiple word characters

That would get all parts that look like @ifttt.com and then we replace the capturing group (= the @) with @ + "zero width space" so that there is a space between the @ and the domain part

@marcomaroni-github
Copy link
Owner

@tibor It seems to me a too drastic replacement, it would be better if the code did not completely eliminate the handle perhaps but transforming it into something that is not ambiguous between a url and a handle, like @iffttt.com -> iffttt.com. But it's a hypothesis what do you think?

@tibor
Copy link
Contributor Author

tibor commented Nov 10, 2024

I’m not sure, what is the difference between @iffttt.com and iffttt.com? Do you mean deleting the @?

@marcomaroni-github
Copy link
Owner

Do you mean deleting the @?

yes

@tibor
Copy link
Contributor Author

tibor commented Nov 10, 2024

Okay, my solution is a similar approach. Instead of deleting the @ it replaces it by @ + a zero width space. So it looks optically like the original tweet but isn’t a handle anymore.
instead of @iffttt.com
it’s @<zero width space>iffttt.com

@marcomaroni-github
Copy link
Owner

@tibor It seems to me that your code removes everything after @

var l = '@IFTTT Do you know what would really rock? A personal @ifttt.com address, so that I would get a SMS when amazon pricewatch sends a mail.'.replaceAll(/(@)[^\s]+\.\w+/g, "@​");
console.log(l);

-----------------
@IFTTT Do you know what would really rock? A personal @​ address, so that I would get a SMS when amazon pricewatch sends a mail.

Am I missing something?

@tibor
Copy link
Contributor Author

tibor commented Nov 10, 2024

Sorry, fixed it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants