Regex to match alphanumeric string with letters, if present, to form at least one sequence of 3+ letters

Ethan

This works wrong. for example this is right - ddd, 2ddd, 2d2ddd, w4hh2www and 2dd, 2d2d2d, dd2d, dd2dd2dd2d this is a wrong, but its working not correctly, /^[a-zA-Z0-9]+[a-zA-Z]{2}/ or /^[a-zA-Z0-9]+[a-zA-Z]{3}/

Yevgen Gorbunkov

You may try that one: /(^[a-z\d]*[a-z]{3}[a-z\d]*$)|(^\d+$)/i

const src = ['2ttt78','q6n','44aaa78','a8','!bbb9','9c','9ddd','2w2www','2d2d2d', '78'],

      pattern = /(^[a-z\d]*[a-z]{3}[a-z\d]*$)|(^\d+$)/i
      
      src.forEach(s =>
        console.log(`${s} is valid: `, pattern.test(s)))
.as-console-wrapper{min-height:100%;}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

REGEX - Check to make sure string has at least two digits, at least two non-alphanumeric characters, and at least two letters?

Regex to match 4 letters in a string

Regex for alphanumeric string including at least one digit

Python regex for sequence containing at least two digits/letters

Regex for match beginning with 2 letters and ending with 3 letters

Javascript Regex: Match any series of letters, unless they match a specific sequence

Regex to match a string with 2 capital letters only

Regex match of a string with numbers and uppercase letters failing

regex to match a string with mixed capital letters and \n

Match letters in R regex

Match regex letters and number

RegEx to match numbers with letters

At least 2 letters in regex pattern

At least 2 different letters in regex

PHP (Regex) Check if a string contains at least 4 digits + 2 letters

Regex: how to know that string contains at least 2 upper case letters?

How to write a regex that matches a string containing at least 4 letters?

Regex for 2 words minimun with at least 3 letters each

How to find words in a string containing at least one underscore and capital letters

Regex to check for 3 same letters in a string?

Regex for alphanumeric with at least one digit

python regex to find alphanumeric string with at least one letter

Regex Python except a sequence of letters

Most efficient regex for checking if a string contains at least 3 alphanumeric characters

Is there a regex to match letters exept vowels using only one hook []?

Regex targets multiple letters as one match, causing problems in my code

Regex expression to detect a string-number combination that is 10-20 in length and needs to have at least 3 capital letters and other conditions

Regex to match 2 letters separately

Regex match exact number of letters