Skip to content

Instantly share code, notes, and snippets.

@franciscojsc
Created October 31, 2021 20:42
Show Gist options
  • Save franciscojsc/c4c78e8f21e4035f664334e0f7a32b23 to your computer and use it in GitHub Desktop.
Save franciscojsc/c4c78e8f21e4035f664334e0f7a32b23 to your computer and use it in GitHub Desktop.
Como negar palavra(s) utilizando Regex

Regex para negar palavra(s)

Para negar o Regex se a palavra foo é unica:

^(?!foo$).*

Para negar o Regex se a palavra foo inicia a frase:

^(?!foo).*

Para negar o Regex se a palavra estiver em qualque lugar na frase:

^(?!.*foo).*

Para negar o Regex se as palavras foo ou bar estiverem em qualque lugar na frase:

^(?!.*foo|.*bar).*

Fonte

ti-enxame.com. Como negar uma palavra específica no regex?. Disponível em: https://www.ti-enxame.com/pt/regex/como-negar-uma-palavra-especifica-no-regex/967401563/. Acesso em: 31 out. 2021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment