Please don't do that... little Unicode BABY ANGELs like this one 👼 are dying! ◕◡◕ (← these are not images) (nor is the arrow!)

And you are killing 20 years of DOS :-) (the last smiley is called WHITE SMILING FACE... Now it's at 263A... But in ancient times it was ALT-1)

and his friend

BLACK SMILING FACE... Now it's at 263B... But in ancient times it was ALT-2

Try a negative match:

Pattern regex = Pattern.compile("[^A-Za-z0-9]");

(this will ok only A-Z "standard" letters and "standard" 0-9 digits.)

Answer from xanatos on Stack Overflow
🌐
KNIME Community
forum.knime.com › knime analytics platform
RegexMatcher for Special Characters - KNIME Analytics Platform - KNIME Forum Archive
October 6, 2023 - Only below special characters are valid "[a-zA-Z][0-9]^_=!#$%&()*+,-.:'/?@ ") If any other special character appears other than above, it needs to say false. Eg: In the above special characters, there is no “|,~”. If ...
Discussions

Regex for all special characters
Do the special characters need to be separated by spaces when put into the list? Or, can they be one after the other like that · I would encourage you to try out a test site as well where you can paste in your regex and test strings and make sure they trigger as expected. More on community.spiceworks.com
🌐 community.spiceworks.com
4
1
June 8, 2024
Regex Expression for string which should contain only limited type of special characters
How can i check if my string contains Special Characters other than the following special characters. curly brackets ( ) Square Brackets Apsotrophe ’ slash / My String should return false if any special charaters are present other than the above(alphanumeric is accepted) Can someone please help. More on forum.uipath.com
🌐 forum.uipath.com
7
0
May 22, 2023
Regex to find and output all special characters in a string
Hi, I´m trying to parse all special characters that I´ve in the Regex expression. The goal is to obtain a string with all the characters that were found. However, I´m able to find only the first ocurrence. Please, If anyone can tell me how I can I get all the characters. Regards! REGEX Special ... More on community.alteryx.com
🌐 community.alteryx.com
July 4, 2019
regular expression - Regex for Password. Restricting Special Characters - Unix & Linux Stack Exchange
The dot in a regex means any character, and you put .{8,}$ at the end. Is this what you want ? This looks wrong to me. ... So the conditions are: 1) Password must be at least 8 characters long; 2) There must be at least one lower case, one upper case, and one number; 3) The only special characters allowed ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
September 12, 2017
🌐
NTU Singapore
www3.ntu.edu.sg › home › ehchua › programming › howto › Regexe.html
Regular Expression (Regex) Tutorial
The fundamental building blocks of a regex are patterns that match a single character. Most characters, including all letters (a-z and A-Z) and digits (0-9), match itself. For example, the regex x matches substring "x"; z matches "z"; and 9 matches "9". Non-alphanumeric characters without special meaning in regex also matches itself.
🌐
3SL
threesl.com › home › blog › special characters in regexes and how to escape them
Special characters in regexes and how to escape them
February 3, 2023 - For instance, regular expressions (regexes) can be used in queries to find all items in which any frame, or a specific frame, or any of a list of frames, contains text matching the regular expression that you are searching for. For example, if you wanted to find all items containing sequences of capital letters followed by numbers, then the regular expression would be: ... Finished\? matches “Finished?” ^http matches strings that begin with http [^0-9] matches any character not 0-9 ing$ matches “exciting” but not “ingenious” gr.y matches “gray“, “grey” Red|Yellow matches “Red” or “Yellow” colou?r matches colour and color Ah?
🌐
Praat
fon.hum.uva.nl › praat › manual › Regular_expressions_1__Special_characters.html
Regular expressions 1. Special characters
Example: ".a" matches two consecutive characters where the last one is "a". Example: ".*\.txt$" matches all strings that end in ".txt". * the asterisk is the match-zero-or-more quantifier. Example: "^.*$" matches an entire line. + the plus sign is the match-one-or-more quantifier. ? the question mark is the match-zero-or-one quantifier. The question mark is also used in special constructs with parentheses and in changing match behaviour.
Find elsewhere
🌐
UiPath Community
forum.uipath.com › help › studio
Regex Expression for string which should contain only limited type of special characters - Studio - UiPath Community Forum
May 22, 2023 - How can i check if my string contains Special Characters other than the following special characters. curly brackets ( ) Square Brackets Apsotrophe ’ slash / My String should return false if any special charaters …
🌐
Regular-Expressions.info
regular-expressions.info › characters.html
Regex Tutorial: Literal Characters and Special Characters
Note that 1+1=2, with the backslash omitted, is a valid regex. So you won’t get an error message. But it doesn’t match 1+1=2. It would match 111=2 in 123+111=234, due to the special meaning of the plus character. If you forget to escape a special character where its use is not allowed, such ...
🌐
Jazz Community Site
jazz.net › dxl › html › 2155 - Special Characters in Regular Expressions.html
Special Characters in Regular Expressions
Greetings, I was hoping that someone in the forum has solved this issue. My dxl script goes through and puts attribute names in an array. I then make another array of regular expressions that have the attribute names and additional things (operations, and semiphores, but that is not important).
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions
Regular expressions - JavaScript | MDN
Use the constructor function when ... of simple characters, such as /abc/, or a combination of simple and special characters, such as /ab*c/ or /Chapter (\d+)\.\d*/. The last example includes parentheses, which are used as a memory device....
🌐
Alteryx
community.alteryx.com › home › participate › discussions › alteryx one
Regex to find and output all special characters in a string - Alteryx
July 4, 2019 - Hi, I´m trying to parse all special characters that I´ve in the Regex expression. The goal is to obtain a string with all the characters that were found. However, I´m able to find only the first ocurrence. Please, If anyone can tell me how I can I get all the characters. Regards! REGEX Special ...
Top answer
1 of 3
3

Regex:

^(?=[a-zA-Z0-9#@$?]{8,}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9]).*

Explanation:

In the regex you provided, the lookaheads serves to ensure your string met some specific conditions, but they are not the real filter which keeps out undesired strings. You specified the following conditions:

  • (?=.*?[A-Z]): Match at least one uppercase letter.
  • (?=.*?[a-z]): Match at least one lowercase letter.
  • (?=.*?[0-9]): Match at least one number.
  • (?=.*?[#@$?]): Match at least one of these characters: #@$?
  • .{8,}: Match any character at least 8 times.

But there are at least two flaws:

  • The (?=.*?[#@$?]) part is unnecessary because those special characters are meant to be optional, not mandatory[1].

  • As I said before, you did not specify a real filter, so thanks to the .{8,} part, your regex will accept any string as long as it meets the conditions established by the lookaheads, even if it has undesired special characters[1].

So to solve those flaws it is necessary to:

  • Delete the (?=.*?[#@$?]) part.

  • Add a new lookahead that acts as the filter mentioned above.

To construct this filter, you should think "which characters I want to allow?" instead of "which characters I want to disallow?", because that is a easier scenario to handle in this specific case. If you say you only want a-z, A-Z, 0-9 and #@$? to be your allowed characters, then the lookahead should look like this:

(?=[a-zA-Z0-9#@$?])

But hey, in this step you can even set the minimum length and tell the lookahead where to start and where to stop (the start and end of string in this case):

(?=[a-zA-Z0-9#@$?]{8,}$)

I omitted the ^ here because it's already at the beggining of everything, so it's not necessary to be redundant. Now we just bring together all the lookaheads and match the valid password using .* instead of .{8,}:

^(?=[a-zA-Z0-9#@$?]{8,}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9]).*

Note:

  1. Although, in the regex and examples you provided, I don't really know why: 1) #@$? were not treated as mandatory; 2) undesired characters were only allowed at the end of the string and not in another place. Maybe it has something to do with the regex engine used by AWS, because everything worked as expected when I tested it on my own.
2 of 3
3

We want a lookahead anchored at the string start for each required character type as well as the length requirement. Then a simple .* to slurp it all up:

^(?=[0-9a-zA-Z#@\$\?]{8,}$)(?=[^a-z]*[a-z])(?=[^A-Z]*[A-Z])(?=[^0-9]*[0-9]).*

Explanation:

First off, I decided to avoid use of the lazy quantifier when matching required char types (e.g. one uppercase) for the following reasons:

  • They are expensive.
  • Different regex engines have different ways of signifying lazy. (A couple don't support it at all.)
  • They aren't as common/familiar as the alternative.

So for efficiency, readability and "portability" I'm using the ^[^x]*[x] construct.

Now breaking the rest down...

^ : Everything anchored to the start

(?=[0-9a-zA-Z#@\$\?]{8,}$) : Lookahead with 8 or more of your allowed characters between start and end of string.

The next three use the same pattern: a lookahead matching zero or more of a char not matching a required char, then the required char. These are all anchored to the beginning so the effect is to allow a match of the required char at any position in the string:

(?=[^a-z]*[a-z]) : At least one lowercase.

(?=[^A-Z]*[A-Z]) : At least one uppercase.

(?=[^0-9]*[0-9]) : At least one digit.

.* : Everything above is lookahead which doesn't consume anything so consume it all here. The first lookahead makes sure the entire string is valid chars so this is safe.

I make no claims about this being optimized (except for avoiding lazy quantifier). This is simply one of the easier forms to comprehend.


Note: the cause of the problem you observed with #@$? is due to the lookahead not being anchored to the end of string. Any character will match after one of those four (and not necessarily just in the last position). Of course, you can't just add $ since that then crowds out valid characters. That's why I include all valid characters in the same lookahead.

🌐
ServiceNow Community
servicenow.com › community › developer-forum › using-regex-to-make-special-characters-disappear-except-when-it › m-p › 2574305
Using regex to make special characters disappear except when it is a dash. How do you do that?
May 31, 2023 - // Step 1: Remove special characters const regex = /[^a-zA-Z0-9\s\-]/g; var transformedString = nameString.replace(regex, ''); ... Hi I tried that and it did not work. It is still removing - all together.
🌐
How to do in Java
howtodoinjava.com › home › java regular expressions › regex – match any character(s)
Regex - Match Any Character or Set of Characters
August 27, 2023 - By default, the '.' dot character in a regular expression matches a single character without regard to what character it is. The matched character can be an alphabet, a number or, any special character.
🌐
QBasic on Your Computer
chortle.ccsu.edu › finiteautomata › Section07 › sect07_12.html
Basic Regular Expressions: Exclusions
The character '.' (period) is a metacharacter (it sometimes has a special meaning). But inside of brackets it does not have a special meaning. It stand for just itself. (Most metacharacters, when used inside of brackets, stand for just themselves.) Bug Alert! The regular expression [^Z] matches all characters other than capital 'Z'. This includes lower case characters, digits, spaces, ..., everything but 'Z'. (The bug is to mistakenly assume that [^Z] matches only uppercase 'A' through 'Y'. If this is what you want, use [A-Y] ).
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions › Cheatsheet
Regular expression syntax cheat sheet - JavaScript | MDN
2 weeks ago - This page provides an overall cheat sheet of all the capabilities of RegExp syntax by aggregating the content of the articles in the RegExp guide. If you need more information on a specific topic, please follow the link on the corresponding heading to access the full article or head to the guide. Character classes distinguish kinds of characters such as, for example, distinguishing between letters and digits.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations
If the first character of the set is '^', all the characters that are not in the set will be matched. For example, [^5] will match any character except '5', and [^^] will match any character except '^'. ^ has no special meaning if it’s not the first character in the set.
🌐
Dataquest
dataquest.io › home › cheat sheets › python regex cheat sheet
Python Regex Cheat Sheet
July 22, 2025 - Special characters become literal inside a set, so this matches (, +, *, and ). ... The ^ negates the set, matching any character not in the set. Here, it matches characters that are not e, r, or s. ... Matches all alphanumeric characters (a-z, A-Z, and 0-9).
🌐
Reddit
reddit.com › r/regex › allow special characters but not spaces?
r/regex on Reddit: Allow special characters but not spaces?
December 23, 2020 -

Wondering if there is a clean way to do this where you could use \W instead of spelling out every one of the allowed special characters.

[A-Za-z0-9@!#$%&*()_+-=//.,";:{}|...etc etc] for example, is so ugly but it works to exclude spaces from a password validation while allowing other special characters, letters, and numbers.

I have not been successful in finding a way to neaten it up to [A-Za-z0-9\W] with something short and sweet to say "except for spaces" at the beginning, middle, end.

Any thoughts? Thanks!