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

153
Views
Need help figuring out how to write this Regex properly

I am trying to make a regex test that returns true for the following conditions:

  • Can only have letters A-F (case insensitive)
  • First character must be '#'
  • Can have numbers 0-9
  • Does not have punctuation

The order does not matter except that string[0] should be '#'.

So far I have: /^#[A-F0-9^!G-Z]/i but for some reason, it returns strings that have letters after F (like G or J) as true.

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

0

You can use

^#[0-9A-Fa-f]*$

Details:

  • ^ - start of string
  • # - a hash symbol
  • [0-9A-Fa-f]* - zero or more hex chars (note it can be written as [[:xdigit:]]* in some regex flavors, but not in ECMAScript flavor used in JavaScript)
  • $ - end of string.
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!