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

88
Visualizações
JS Regex match word starting with character but ignore if it's double

So I have this regular exp :: /(?:^|\W)\£(\w+)(?!\w)/g

This is meant to match words following the character £ . ie; if you type Something £here it will match £here .

However, if you type ££here I don't want it to be matched, however, i'm unsure how to match £ starting but ignore if it's ££.

Is there guidance on how to achieve this?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can add £ to \W:

/(?:^|[^\w£])£(\w+)/g

Actually, (?!\w) is redundant here (as after a word char, there is no more word chars) and you can remove it safely.

See the regex demo. Details:

  • (?:^|[^\w£]) - start of string or any single char other than a word and a £ char
  • £ - a literal char
  • (\w+) - Group 1: one or more word chars.
about 4 years ago · Juan Pablo Isaza Relatório

0

If you also don't want to match $£here

(?<!\S)£(\w+)

Explanation

  • (?<!\S) Assert a whitespace boundary to the left
  • £ Match literally
  • (\w+) Capture 1+ word characters in group 1

See a regex101 demo.


If a lookbehind is not supported:

(?:^|\s)£(\w+)

See another regex101 demo.

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