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

115
Views
Regular expression that matches a single word in any order

After a long, unsuccessful search I am starting to wonder if what I am looking for is possible, I would like a regular expression which requires that each letter chosen is mandatory but only once and in any order.

Example : ^[abc]{3}$

The result I expect would be that it matches only that :

abc, bac, cba, acb

While I get :

acc, abb, cca, aab

Do you see where I am going with this?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You may use a regex like this with a negative lookahead of the matched character in a back-reference:

^(?:([abc])(?!.*\1)){3}$

RegEx Demo

about 4 years ago · Juan Pablo Isaza Report

0

Here is another way.

^(?!.*([abc]).*\1)[abc]{3}$

Demo

The negative lookahead

(?!.*([abc]).*\1)

asserts that no character is repeated and

[abc]{3}

together with the two anchors asserts that the string has a length of three and is composed of the characters in the character class.

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!