Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda