Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
Need regex for project name with the following conditions

Need regex for the "Project name" with following condition. Expected Result: Take alphabetical, alpha numeric, alpha numeric symbolic Actual Result:

1.    Take alpha – Pass
2.    Take Numeric – Pass
3.    Take Alpha numeric – Pass
4.    Take alpha numeric special characters - Pass
5.    If Only special characters – Fail

that is, Everything is allowed but if it is just special characters and no text than it's a problem. **Example:

  • zjna5726$7&^#bsg //allowed
  • %&*% // just special characters not allowed
  • I tried /^[ A-Za-z0-9_@./#&+-]*$/ but did not help
  • ^([\w+\d+]+)((-)([\w+\d+]+))* //did not help it is only excepting one character in between only.
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Is not just simply to check that this has a match ? /\w+/

if (teststring.match(/\w+/) != null) ..

about 4 years ago · Juan Pablo Isaza Relatório

0

Why don't you just check if there is included Numeric or Alpha?

if("string".match(/A-Za-z0-9/)) // do something
else // do something else
about 4 years ago · Juan Pablo Isaza Relatório

0

^(?=[\W_]+[a-zA-Z0-9]|[a-zA-Z0-9]+[\W_]|[a-zA-Z0-9]+).+$ - This regex should fulfil your requirement.

alpha="abc"
numeric="123456789"
alphaNumeric="Abc1234"
alphaNumericSpcl="#Abc1234$!@~!"
onlySpcl="!@#$%^&*()_-+={}\|][:;'\".,><?/`"
randomString="!@#$%^&*()_-abde9+={}\|][:;'\".,><?/`"

regex=/^(?=[\W_]+[a-zA-Z0-9]|[a-zA-Z0-9]+[\W_]|[a-zA-Z0-9]+).+$/
console.log("Test of Alpha:",regex.test(alpha));
console.log("Test of Numeric:",regex.test(numeric));
console.log("Test of Alphanumeric:",regex.test(alphaNumeric));
console.log("Test of Alphanumeric and Special:",regex.test(alphaNumericSpcl));
console.log("Test of only Special:",regex.test(onlySpcl));
console.log("Test of Random String:",regex.test(randomString));

Output:

Test of Alpha: true
Test of Numeric: true
Test of Alphanumeric: true
Test of Alphanumeric and Special: true
Test of only Special: false
Test of Random String: true
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda