De um tutorial de Regex - Caracteres Literais e Caracteres Especiais:
Como queremos fazer mais do que simplesmente buscar por pedaços literais de texto, precisamos reservar certos caracteres para uso especial. Há pelo menos 12 caracteres com significados especiais:
a barra invertida \, o acento circunflexo ^, o sinal de dólar $, o ponto ou dot ., a barra vertical ou pipe |, o ponto de interrogação ?, o asterisco ou star *, o sinal de mais +, o parêntese de abertura (, o parêntese de fechamento ), o colchete de abertura [, e a chave de abertura {, Esses caracteres especiais são frequentemente chamados de “metacaracteres”. A maioria deles são erros quando usados sozinhos.
Se você quiser usar qualquer um desses caracteres como literal em uma regex, você precisa escapar-los com uma barra invertida. Se você quiser corresponder a 1+1=2, a regex correta é 1\+1=2. Caso contrário, o sinal de mais tem um significado especial.
E no PT, muitas vezes precisamos do \ em uma regex, porque é tão fundamental para os usfms. Então, para buscar por \p em uma regex, você digita \\p.
(É útil aprender sobre escape, pois mesmo nesta ferramenta de fórum, certos caracteres não serão renderizados, a menos que você os escape ou use o recurso de “texto pré-formatado” via ícone </>.)
From a Regex Tutorial - Literal Characters and Special Characters:
Because we want to do more than simply search for literal pieces of text, we need to reserve certain characters for special use. There are at least 12 characters with special meanings:
the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing parenthesis ), the opening square bracket [, and the opening curly brace {, These special characters are often called “metacharacters”. Most of them are errors when used alone.
If you want to use any of these characters as a literal in a regex, you need to escape them with a backslash. If you want to match 1+1=2, the correct regex is 1\+1=2. Otherwise, the plus sign has a special meaning.
And in PT, we often need the \ in a regex, because it is so fundamental for usfms. So to search for \p in a regex, you type \\p.
(It is useful to learn about escaping, as even in this forum-tool, certain characters will not render, unless you either escape them or use the “preformatted text” feature via the </> icon.)
Tradução automática de English