Skip to content
Advertisement

RegEx for Javascript to allow only alphanumeric

I need to find a reg ex that only allows alphanumeric. So far, everyone I try only works if the string is alphanumeric, meaning contains both a letter and a number. I just want one what would allow either and not require both.

Advertisement

Answer

JavaScript

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-9u0600-u06FFu0660-u0669u06F0-u06F9 _.-]+)$/

this will support persian.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement