Skip to main content
DevTools24

정규식 이스케이프

문자 그대로 매칭하기 위해 특수 정규식 문자를 이스케이프합니다. 대체 문자열 이스케이프도 처리합니다.

For replacement strings, only $ needs escaping (as $$)

.Any character
*0 or more
+1 or more
?0 or 1
^Start of string
$End of string
{Quantifier start
}Quantifier end
(Group start
)Group end
[Class start
]Class end
|Alternation
\Escape character

Regex Special Characters - 기술 세부 정보

Special regex characters like . * + ? ^ $ { } ( ) | [ ] \\ have special meanings. To match them literally, prefix with a backslash. For replacement strings, $ needs to be escaped as $$.

명령줄 대안

// JavaScript regex escape function
function escapeRegex(str) {
  return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}

참조

공식 사양 보기