How do I block or restrict special characters from input fields with jquery?

A simple example using a regular expression which you could change to allow/disallow whatever you like. $(‘input’).on(‘keypress’, function (event) { var regex = new RegExp(“^[a-zA-Z0-9]+$”); var key = String.fromCharCode(!event.charCode ? event.which : event.charCode); if (!regex.test(key)) { event.preventDefault(); return false; } });

removing emojis from a string in Python

On Python 2, you have to use u” literal to create a Unicode string. Also, you should pass re.UNICODE flag and convert your input data to Unicode (e.g., text = data.decode(‘utf-8′)): #!/usr/bin/env python import re text = u’This dog \U0001f602’ print(text) # with emoji emoji_pattern = re.compile(“[” u”\U0001F600-\U0001F64F” # emoticons u”\U0001F300-\U0001F5FF” # symbols & pictographs … Read more