/^[a-z0-9]+$/i

^         Start of string
[a-z0-9]  a or b or c or ... z or 0 or 1 or ... 9
+         one or more times (change to * to allow empty string)
$         end of string    
/i        case-insensitive

Update (supporting universal characters)

if you need to this regexp supports universal character you can find list of unicode characters here.

for example: /^([a-zA-Z0-9\u0600-\u06FF\u0660-\u0669\u06F0-\u06F9 _.-]+)$/

this will support persian.

Answer from Greg on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-validate-an-input-is-alphanumeric-or-not-using-javascript
How to Validate an Input is Alphanumeric or not using JavaScript? - GeeksforGeeks
July 12, 2025 - RegExp is used to check the string of invalid characters that don't contain (a-z) alphabets and all numeric digits to validate. A not operator is used for the desired output. Example: This example implements the above approach.
Discussions

Help me with my regex that only accepts alpha characters, hyphens, and spaces with a minimum of seven characters please
Add a space into the [A-Za-z0-9-] block, like [A-Za-z0-9- ] More on reddit.com
🌐 r/learnprogramming
7
6
November 4, 2022
Regex Alphanumeric and Certain Special Characters
Hello fellow RPA Developers, I would like to ask for help for Regex of Alphanumeric and Certain Special Characters. Input: Washington St., (Poblacion 3), St@a. Rita City, “New-York”, U/SA Expected Output: Washington St., Poblacion 3, Sta. Rita City, New York, USA As you can see on the output, ... More on forum.uipath.com
🌐 forum.uipath.com
6
0
August 7, 2023
🌐
RegExr
regexr.com › 3a8p3
RegExr: Learn, Build, & Test RegEx
RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp). Supports JavaScript & PHP/PCRE RegEx.
🌐
regex101
regex101.com › library › hI9cR2
regex101: Alphanumeric and Spaces
Number Length: The phone number must have exactly 8 digits following the operator code, for a total of 11 digits (including the country code and operator code). This regex is commonly used to ensure that the input phone numbers follow the standard ...
🌐
LabEx
labex.io › tutorials › string-is-alphanumeric-28407
Checking if a String is Alphanumeric | LabEx
In the WebIDE, navigate to the file explorer on the left side and create a new JavaScript file: ... Once you have created the file, it should open automatically in the editor. If not, click on alphanumeric.js in the file explorer to open it. ... // Function to check if a string is alphanumeric function isAlphaNumeric(str) { // Using regular expression to check for alphanumeric characters return /^[a-zA-Z0-9]+$/.test(str); } // Example usage console.log("Is 'hello123' alphanumeric?", isAlphaNumeric("hello123")); console.log("Is '123' alphanumeric?", isAlphaNumeric("123")); console.log("Is 'hello 123' alphanumeric?", isAlphaNumeric("hello 123")); console.log("Is 'hello@123' alphanumeric?", isAlphaNumeric("hello@123"));
🌐
Plain English
plainenglish.io › home › blog › javascript › check if string is alphanumeric in javascript
Check if string is Alphanumeric in JavaScript
December 31, 2022 - The ^ and $ symbols anchor the pattern to the start and end of the string, so that the regular expression will only match the entire string, not just a part of it. The + symbol after the character set means that the pattern should match one ...
Find elsewhere
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › string › string is alpha or alphanumeric
Check if a JavaScript string contains only alpha or alphanumeric characters - 30 seconds of code
March 24, 2024 - const isAlphaNumeric = str => /^[a-z0-9]*$/gi.test(str); isAlphaNumeric('hello123'); // true isAlphaNumeric('123'); // true isAlphaNumeric('hello 123'); // false (space character is not alphanumeric) isAlphaNumeric('#$hello'); // false ... These methods can serve as a great starting point for more complex string validation patterns. You can further customize the regular expressions to suit your specific requirements (e.g. allowing spaces, hyphens, or underscores in the string). ... Learn how to work with whitespaces in JavaScript strings, using these simple yet powerful regular expression techniques.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-validate-an-input-is-alphanumeric-or-not-using-javascript
How to validate an input is alphanumeric or not using JavaScript?
March 15, 2026 - Regular expressions provide a more concise and efficient way to validate alphanumeric strings. The pattern /^[a-z0-9]+$/i matches strings containing only letters and numbers. let regex = /^[a-z0-9]+$/i; let isAlphanumeric = regex.test(string);
🌐
UiPath Community
forum.uipath.com › help › studio
Regex Alphanumeric and Certain Special Characters - Studio - UiPath Community Forum
August 7, 2023 - Hello fellow RPA Developers, I would like to ask for help for Regex of Alphanumeric and Certain Special Characters. Input: Washington St., (Poblacion 3), St@a. Rita City, “New-York”, U/SA Expected Output: Washington St., Poblacion 3, Sta. Rita City, New York, USA As you can see on the output, ...
🌐
DEV Community
dev.to › tillsanders › let-s-stop-using-a-za-z-4a0m
Let's stop using [a-zA-Z]+ - DEV Community
March 9, 2021 - const regex = /^[\p{Letter}\p{Mark}]+$/u regex.test(burmese) // true regex.test(town) // true ... Till Sanders – Designer and Web Developer from the cloudy mountains of Lüden­scheid. Spent the last decade learning about and shaping the difficult interaction between human and metal minds. ... Currently interested in TypeScript, Vue, Kotlin and Python. Looking forward to learning DevOps, though. ... A while ago, I also learnt that JavaScript regex has unicode support (via /.../u).
🌐
YouTube
youtube.com › watch
JavaScript Alpha Numeric Validation using Regular Expression - YouTube
AboutPressCopyrightContact usCreatorsAdvertiseDevelopersTermsPrivacyPolicy & SafetyHow YouTube worksTest new featuresNFL Sunday Ticket · © 2025 Google LLC
Published   November 4, 2018
🌐
IT Explore
itexplore.org › homepage › tips › validating strings as alphanumeric symbols using regex in javascript
Validating Strings as Alphanumeric Symbols Using Regex in JavaScript | IT Explore
May 8, 2025 - To check if a string contains only alphanumeric symbols using regular expressions, use ^[ -~]+$. This regular expression matches strings composed of one or more alphanumeric symbols, such as "Hello, world!".
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions › Character_classes
Character classes - JavaScript | MDN
March 17, 2026 - const nonEnglishText = "Приключения Алисы в Стране чудес"; const regexpBMPWord = /([\u0000-\u0019\u0021-\uFFFF])+/gu; // BMP goes through U+0000 to U+FFFF but space is U+0020 console.table(nonEnglishText.match(regexpBMPWord)); ["Приключения", "Алисы", "в", "Стране", "чудес"];
🌐
Code2night
code2night.com › Blog › MyBlog › Alphanumeric-validation-in-JavaScript
Alphanumeric validation in JavaScript | Code2night.com
August 14, 2022 - We are using event keycodes for validating alphanumeric data in the textboxes. <script> function onlyAlphanumerics(e) { var regex = new RegExp("^[a-zA-Z0-9]+$"); var str = String.fromCharCode(!e.charCode ?
🌐
Quora
quora.com › What-is-the-most-optimal-way-to-check-if-a-string-is-alphanumeric-in-JavaScript-without-using-regex
What is the most optimal way to check if a string is alphanumeric in JavaScript without using regex? - Quora
Answer (1 of 2): Iterate over the string using .charCodeAt(index) and check if each value is in the range 48–57 (number) 65–90 (capital letter) or 97–122 (lower-case letter). Anything outside those ranges is not alphanumeric in English (though you may decide to alter this for accented ...
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions › Cheatsheet
Regular expression syntax cheat sheet - JavaScript | MDN
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.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-program-to-remove-non-alphanumeric-characters-from-a-string
JavaScript Program to Remove Non-Alphanumeric Characters from a String | GeeksforGeeks
July 10, 2024 - By iterating through each character in the string and checking if it's alphanumeric, we can construct the resulting string without non-alphanumeric characters.