[^a-zA-Z\d\s:]
  • \d - numeric class
  • \s - whitespace
  • a-zA-Z - matches all the letters
  • ^ - negates them all - so you get - non numeric chars, non spaces and non colons
Answer from Tudor Constantin on Stack Overflow
Discussions

RegEx to remove all non alphanumeric characters
Could someone please show me how to use some simple RegEx to do the following please: "String with spaces, punctuation; and numbers (22)" -> "Stringwithspacespunctuationandnumbers22" The only characters I want to retain are letters a-z (case doesn't matter) and numbers 0 to 9. I'm working with ... More on community.alteryx.com
🌐 community.alteryx.com
December 1, 2016
Help with RegEx to find non alphanumeric characters
Hi. I have a table full of names. I am trying to find all names that contain a non alphanumeric character, but I want to exclude spaces, dashes - , and ampersand &. I am trying this: select * from mytable where name like '%[^a-zA-Z0-9 -&/]%' However, I am getting names returned like... More on tek-tips.com
🌐 tek-tips.com
1
0
July 12, 2020
Just a little confused about removing/replacing non-alphanumeric characters
This is RegEx. You can learn RegEx in a fun way at: https://regexcrossword.com/ You can test regex at: http://regexr.com/ What it means that find all instances where the character are not ^ in group of elements inside [] in range of A-Z or a-z or 0-9 so not alphanumeric. More on reddit.com
🌐 r/learnprogramming
2
2
August 10, 2016
Apex: Is there a way to strip out non-alphanumeric characters from a string? - Salesforce Stack Exchange
In order to store results in the newly released (Winter 16') Platform Cache, I need an alphanumeric string, but currently have a String with the report name that I'm attempting to store, some of wh... More on salesforce.stackexchange.com
🌐 salesforce.stackexchange.com
December 18, 2015
🌐
Reddit
reddit.com › r/learnprogramming › how to make a regex that is "non alphanumerics and non apostrophe"?
r/learnprogramming on Reddit: How to make a regex that is "non alphanumerics and non apostrophe"?
June 12, 2021 -

If it matters I want to split a string at any non alphanumeric characters, however doing /[^W]/ doesn't give the desired result because the word "don't" is then split into "don" and "t"

Top answer
1 of 2
4
You're almost there. Let's break down your regex as is: [ ] : Matches anything inside these brackets. For example, /[abc]/ matches any single 'a', 'b', or 'c'. ^: (only at the beginning of a pair of square brackets!) inverts the selection. So altering my previous example, /[^abc]/ matches any single character that is not an 'a', 'b', or 'c'. W: matches the capital letter 'W'. I assume what you meant was \W, which is... still wrong. \W matches anything that isn't an alphanumeric symbol or underscore. So by saying ^\W, you'd essentially be saying "match any single character that is not not (i.e., is) an alphanumeric character or underscore. Alrighty, now let's fix it: Firstly, let's keep the first two bits: [^]. We could use the capital W thing (\W), but that's going to make matching the apostrophe a bit... annoying. We need to match anything ([ ]) that isn't (^) an alphanumeric character (\w, notice lowercase!), or an apostrophe. The apostrophe can just be represented directly by itself: '. So let's toss that all together: /[^\w']/ Final note: the \w selector is "all alphanumerics and underscores. So if your sentence were "This sentence has some weird_spacing, but don't be afraid!", and you wanted "weird_spacing" to be split, you'd need to use something other than \w. In that case, you'd probably want to specify a character range: a-z0-9. If you use the i (case insensitive) flag - /[abc]/i, you can just use your range like that. Without it, you'd also have to specify capital letters. So your full regex for "Match all alphanumeric characters and apostrophes" is: /[^a-z0-9']/i using the case insensitive flag. /[^A-Za-z0-9']/, not using the case insensitive flag.
2 of 2
1
Instead of split, match all the patterns you want. Here's an example with Python: >>> s = """doesn't give the desired result""" >>> re.findall(r"\w+(?:'\w+)?", s) ["doesn't", 'give', 'the', 'desired', 'result']
🌐
Medium
medium.com › @shamzaibrahim7 › three-techniques-to-remove-non-alphanumeric-characters-for-palindrome-problem-9ab7a78d8490
Three Techniques to Remove Non-Alphanumeric Characters for Palindrome Problem | by Syed Hamza | Medium
March 27, 2023 - To use regular expressions to remove non-alphanumeric characters, we can define a regular expression pattern that matches all non-alphanumeric characters, and then use the re.sub() function to replace all matches with an empty string.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-program-to-remove-non-alphanumeric-characters-from-a-string
JavaScript Program to Remove Non-Alphanumeric Characters from a String - GeeksforGeeks
July 23, 2025 - We will see how to remove non-alphanumeric characters from a string in JavaScript. Non-alphanumeric characters are symbols, punctuation, and whitespace.
🌐
IBM
ibm.com › docs › en › nsm › 61.1
Netcool/System Service Monitor
Build, govern, and manage your data for generative AI solutions · Use pre-integrated automation technologies to design, build, and run automation applications and services on the cloud
🌐
SourceForge
regexrenamer.sourceforge.net › help › regex_quickref.html
Regular Expression Quick Reference
Relevent modifiers are i (ignore case) and x (extended regex). ... Any text other than the variables below will be replaced as-is. For unnamed captures, use ${n} if the following character is an actual digit
🌐
Tek-Tips
tek-tips.com › home › forums › software › programmers › dbms packages › microsoft sql server: programming
Help with RegEx to find non alphanumeric characters | Tek-Tips
July 12, 2020 - Hi. I have a table full of names. I am trying to find all names that contain a non alphanumeric character, but I want to exclude spaces, dashes - , and ampersand &. I am trying this: select * from mytable where name like '%[^a-zA-Z0-9 -&/]%' However, I am getting names returned like...
🌐
Quora
quora.com › What-regex-will-match-until-the-first-non-alphanumeric-character
What regex will match until the first non-alphanumeric character? - Quora
Answer (1 of 2): It depends somewhat on what you actually want to match. Do you need to include certain letters in Unicode, or just a-z? If you're just going for a-z and 0-9, you could do something like ^[a-zA-Z0-9]*, which would match "ABCD" in your example. If you want to include whitespace a...
🌐
Regex101
regex101.com › r › jI5hK6 › 1
regex101: Remove Non-Alphanumeric Characters
An explanation of your regex will be automatically generated as you type.
🌐
Baeldung
baeldung.com › home › java › java string › check if a string contains non-alphanumeric characters
Check if a String Contains Non-Alphanumeric Characters | Baeldung
January 8, 2024 - Let’s consider a simple use case, where the application must accept only English digits and alphabet characters. To achieve this, we use regex [^a-zA-Z0-9] to identify a non-alphanumeric character:
🌐
gosamples
gosamples.dev › tutorials › remove non alphanumeric characters from a string in go
🧽 Remove non-alphanumeric characters from a string in Go
May 19, 2022 - This is a classic example of removing non-alphanumeric characters from a string. First, we compile our regular expression that matches any character other than an English letter, number, or space. Then, we use the Regexp.ReplaceAllString() method to replace the matched non-alphanumeric characters with the empty string "".
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations
May 25, 2026 - Matches characters considered alphanumeric in the ASCII character set; this is equivalent to [a-zA-Z0-9_]. If the LOCALE flag is used, matches characters considered alphanumeric in the current locale and the underscore. ... Matches any character which is not a word character. This is the opposite of \w. By default, matches non-underscore (_) characters for which str.isalnum() returns False.
🌐
R Project
search.r-project.org › CRAN › refmans › lsa › html › alnumx.html
R: Regular expression for removal of non-alphanumeric characters...
This character string contains a regular expression for use in gsub deployed in textvector that identifies all alphanumeric characters (including language specific special characters not included in [:alnum:], currently only the ones found in German and Polish.
🌐
Text-Utils
text-utils.com › remove special characters
Remove Special Characters - Online Regex Tools | Text-Utils.com
September 6, 2025 - Keep alphanumeric only: Remove all non-alphanumeric characters from the text.