정규식 이스케이프
문자 그대로 매칭하기 위해 특수 정규식 문자를 이스케이프합니다. 대체 문자열 이스케이프도 처리합니다.
Text to Escape0 chars
Escaped for Regex Pattern
Escaped output...
Escaped for Replacement String
Escaped for replacement...
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 characterRegex 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, '\\$&');
}