Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!