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

159
Vistas
How to combine multiple Unicode character properties in JavaScript?

There are \p{Script=Latin} (also can be written as \p{sc=Latin}) and \p{Uppercase}.

But there is currently no way to select an intersection of multiple sets like /^([ \p{Script=Latin} & \p{Uppercase} ])/ in Perl ≥5.18 or \p{Script=Latin,Uppercase}.

So the task is to find a workaround.

Example input:

const input = [
'License: GPL!',
'License: WÐFPL!',
'License: None!',
]

Example output: ['GPL', 'WÐFPL']

The answer could use use a regexp that looks like this for example: /^License:\s*(?<abbr>\p{Script=Latin,Uppercase}+)!$/u

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

There's no ideal workaround to do that except if you want the intersection of predefined character classes. All you have to do is to use a negation and negated character classes:

/^License:\s*([^\P{Script=Latin}\P{Uppercase}]+)!/u

demo

It is simple set logic:

A ∩ B = ∁∁(A ∩ B)    // complement of a complement is an involution
A ∩ B = ∁(∁A ∪ ∁B)   // Morgan's law: complement of an intersection is the union
                     // of complements
about 4 years ago · Juan Pablo Isaza Denunciar

0

const input = [
'License: GPL!',
'License: WÐFPL!',
'License: None!',
]
const regexp = /^License:\s*(?<abbr>(?:(?![ƗØ])(?=\p{Uppercase})\p{sc=Latin})+)!$/u
console.log(input.map(str => str.match(regexp)?.groups?.abbr).filter(Boolean))

Explanation:

^
License:
\s*
(?<abbr>   // named capture groups
    (?:
        // A negative look-ahead assertion.
        // Exclusion of Ɨ and Ø was not required by the question;
        // this line is here to provide more examples.
        (?![ƗØ])

        // A look-ahead assertion (looks into the future,
        // and then always goes back to the former position)
        (?=\p{Uppercase})

        \p{sc=Latin}
    )+
)
!
$
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