Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda