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

211
Visualizações
JS Regex Help Domain Catcher

I'm currently creating a JavaScript Regex and I can't seem to figure out how to match a specific domain. Here is an example.

I need to create a regex that matches any domain that strictly contains (text.com) but not two domain levels deep. For example:

  • text.com --> match
  • test.text.com --> match

foo.test.text.com will not match as it contains two domain levels past text.com (foo and test) if that makes sense.

So far, I have been able to create a regex that can find any match for one domain level past text.com but it still matches domains it should not. I'm thinking it needs a negative lookahead assertion which I tried but maybe configured incorrectly?

I am using

(?<!\w)(\w+.{1}text\.com)

Here is a link to my current regex editor, any help would be greatly appreciated! https://regex101.com/r/P053fv/1

Example of how many current regex fails: https://i.stack.imgur.com/LtD9R.png

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

0

This regex will match domains ending with text.com and not having more than 1 subdomain:

^([^.]+?\.)?text\.com$
  • ^ from the start of the string
  • ([^.]+?\.)? an optional string group ending with one dot
  • text\.com following text.com
  • $ end of string

https://regex101.com/r/O7zr4K/1

Matching Non matching
text.com foo.test.text.com
test.text.com foo2.no.match.here.text.com
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