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

206
Views
Combine regex with different groups of criteria

I wanted to write a regex that would validate this: info-444444-test.json where 444444 could be any number 0-9 and 6 characters

My current regex is (info-)|(^[0-9]{6}$)|(-test.json) but it does not work on website such as https://regex101.com/

At the end I need to implement the regex into .NET into method It.IsRegex from Moq library.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In your pattern (info-)|(^[0-9]{6}$)|(-test.json) there are 3 alternatives where the pattern is trying to match each alternative starting from the left giving you partial matches.

You can use a pattern to match all the parts as one match.

This is

^info-[0-9]{6}-test\.json$
  • ^ Start of string
  • info- Match literally
  • [0-9]{6} Match 6 digits 0-9
  • -test\.json Match -test.json (Note to escape the dot)
  • $ End of string

See a .NET regex demo

over 4 years ago · Santiago Trujillo 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!