RegExp.leftContext ($`)
Deprecated
Avoid using this feature in new projects.
The RegExp static properties may have unintended side effects.
This feature may be a candidate for removal from web standards or browsers. >
ì°¸ê³ :
ë§ì§ë§ ì¼ì¹ ìí를 ì ìì ì¼ë¡ ë
¸ì¶íë 모ë RegExp ì ì ìì±ì ë ì´ì ì¬ì©ëì§ ììµëë¤. ìì¸í ë´ì©ì ë ì´ì ì¬ì©ëì§ ìë RegExp 기ë¥ì ì°¸ê³ íì¸ì.
RegExp.leftContext ì ì ì ê·¼ì ìì±ì ê°ì¥ ìµê·¼ ì¼ì¹ í목 ìì ìë íì 문ìì´ì ë°íí©ëë¤. RegExp["$`"]ë ì´ ìì±ì ë³ì¹ì
ëë¤.
ì¤ëª
leftContextë RegExpì ì ì ìì±ì´ê¸° ë문ì, ìì±í RegExp ê°ì²´ì ìì±ì¼ë¡ ì¬ì©íë ê²ë³´ë¤ë íì RegExp.leftContext ëë RegExp["$`"]ë¡ ì¬ì©í´ì¼ í©ëë¤.
leftContextì ê°ì RegExp(RegExp íì í´ëì¤ ì ì¸) ì¸ì¤í´ì¤ê° ì¼ì¹ì ì±ê³µí ëë§ë¤ ê°±ì ë©ëë¤. ì¼ì¹íë íëª©ì´ ìì¼ë©´ leftContextë ë¹ ë¬¸ìì´ì
ëë¤. leftContextì ì¤ì ì ê·¼ìë undefinedì´ë¯ë¡ ì´ ìì±ì ì§ì ë³ê²½í ì ììµëë¤.
`ë ì í¨í ìë³ì ë¶ë¶ì´ ìëë¯ë¡ ì ìì± ì ê·¼ì(RegExp.$` )ì í¨ê» ì½ì¹ì ì¬ì©í ì ìì¼ë©° ì´ë¡ ì¸í´ SyntaxErrorê° ë°ìí©ëë¤. ëì ëê´í¸ í기ë²ì ì¬ì©íì기 ë°ëëë¤.
$` ë String.prototype.replace()ì ëì²´ 문ìì´ìë ì¬ì©í ì ìì§ë§, ì´ë RegExp["$`"] ë ê±°ì ìì±ê³¼ë ê´ë ¨ì´ ììµëë¤.
ìì
>leftContextì $` ì¬ì©í기
const re = /world/g;
re.test("hello world!");
RegExp.leftContext; // "hello "
RegExp["$`"]; // "hello "
ëª ì¸ì
| Specification |
|---|
| Legacy RegExp features > # additional-properties-of-the-regexp-constructor > |