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

212
Visualizações
Regex to check if any latin letter except specific ones is present in string using javascript

My task is to check if string of an arbitrary length contains any latin letter except specific ones (in my case letters that match roman numerals (I,V,X,L,C) are not allowed)

So if no latin letter is present - the string is invalid, if specific character (mentioned above) is present - the string is invalid. Otherwise the string is valid.

Could someone help me to come up with proper regex for that condition?

Examples:

123 - invalid

123 aAA - valid

ABD - valid

AAa ddDD zzZz - valid

AXXXA - invalid

IV abc - invalid

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This is a standard RegEx requirement, build a character class of all the characters you want to match. From your question this RegEx should do it for you: /^[^CDILMXV]*(?:[ABE-JKN-UWY-Z])+[^CDILMXV]*$/i

Note: I am allowing for more roman numerals than you had in your post, if that.s not what you need adjust accordingly.

The RegEx must have at least one allowed latin character (the middle part (?:[ABE-JKN-UWY-Z])+ and there must be no disallowed latin characters before or after the middle match (the [^CDILMXV]* at the start and end)

This should match all of your inputs.

about 4 years ago · Juan Pablo Isaza Relatório

0

This should be it. First part (?=.*[a-z]) checks for latin letters, and [^XLVCI] mathes anything besides these characters.

let string1 = '123'
let string2 = '123 aAA'
let string3 = 'ABD'
let string4 = 'AAa ddDD zzZz'
let string5 = 'AXXXA'
let string6 = 'IV abc'

let regex = /^(?=.*[a-zA-Z])[^XLVCI]+$/

let result = string1.match(regex)

console.log(string1.match(regex))
console.log(string2.match(regex))
console.log(string3.match(regex))
console.log(string4.match(regex))
console.log(string5.match(regex))
console.log(string6.match(regex))

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