-
-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/emoji strip #56
Conversation
At first I did implement a much simpler version; something like: var newStr = Emoji.unemojify(str);
var cleaned = Emoji.emojify(str, () => '', () => '');
return cleaned.trim(); It seemed to do it's thing, but the double iteration didn't feel right. Also, I think So I've decided to implement the function in a similar way as the unemojify. Loop over the words, clean spaces when wanted and necessary, and return the string. |
@@ -10,6 +10,12 @@ var emojiByName = require('./emoji.json'); | |||
var emojiNameRegex = /:([a-zA-Z0-9_\-\+]+):/g; | |||
|
|||
/** | |||
* regex to trim whitespace | |||
* use instead of String.prototype.trim() for IE8 supprt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. And you've already merged the thing π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome π
@@ -27,6 +27,8 @@ emoji.find('π'); // Find the `pizza` emoji, and returns `({ emoji: 'π', ke | |||
emoji.find('pizza'); // Find the `pizza` emoji, and returns `({ emoji: 'π', key: 'pizza' })`; | |||
emoji.hasEmoji('π'); // Validate if this library knows an emoji like `π` | |||
emoji.hasEmoji('pizza'); // Validate if this library knowns a emoji with the name `pizza` | |||
emoji.strip('β οΈ γ°οΈ γ°οΈ low disk space'); // Strips the string from emoji's, in this case returns: "low disk space". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are the γ°οΈ
characters getting stripped too? they are not emoji, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they actually are emoji, so this behavior is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wavy_dash
, it's not a ~
, which of course isn't being replaced.
thank you so much - looks good π |
released |
Closes #17
The following functionality is added:
Emoji.replace
And some things can't be done; as discussed in #17
Emoji.strip
Emoji.strip
is a shortcut forreplace(str, '', true);