Baseline Widely available
hasIndices
㯠RegExp
ã¤ã³ã¹ã¿ã³ã¹ã®ããããã£ã§ããã®æ£è¦è¡¨ç¾ã§ d
ãã©ã°ã使ç¨ããããã©ããã示ãã¾ãã
const regex1 = new RegExp("foo", "d");
console.log(regex1.hasIndices);
// Expected output: true
const regex2 = new RegExp("bar");
console.log(regex2.hasIndices);
// Expected output: false
解説
RegExp.prototype.hasIndices
ã®å¤ã¯ d
ãã©ã°ã使ç¨ããã¦ããå ´åã« true
ã¨ãªããããã§ãªãå ´å㯠false
ã¨ãªãã¾ããd
ãã©ã°ã¯ãæ£è¦è¡¨ç¾ã®ç
§åçµæã«åãã£ããã£ã°ã«ã¼ãã®é¨åæååã®éå§ã¨çµäºã®ã¤ã³ããã¯ã¹ãå«ãããã¨ã示ãã¾ããããã¯æ£è¦è¡¨ç¾ã®è§£éãç
§åã®åä½ã夿´ãããã®ã§ã¯ãªããç
§åçµæã«è¿½å æ
å ±ãä¸ããã ãã§ãã
ãã®ãã©ã°ã¯ã主㫠exec()
ã®è¿å¤ã«å½±é¿ãã¾ããd
ãã©ã°ãåå¨ããå ´åãexec()
ã«ãã£ã¦è¿ãããé
åã¯ãexec()
ã¡ã½ããã®è¿å¤ã«è¨è¿°ããã¦ããããã«ã追å ã® indices
ããããã£ãæã¡ã¾ããä»ã®ãã¹ã¦ã®æ£è¦è¡¨ç¾é¢é£ã®ã¡ã½ããï¼String.prototype.match()
ãªã©ï¼ã¯ãå
é¨çã« exec()
ãå¼ã³åºãã®ã§ãæ£è¦è¡¨ç¾ã« d
ãã©ã°ãããå ´åãã¤ã³ããã¯ã¹ãè¿ãã¾ãã
hasIndices
ã®è¨å®ã¢ã¯ã»ãµã¼ã¯ undefined
ã§ãããã®ããããã£ãç´æ¥å¤æ´ãããã¨ã¯ã§ãã¾ããã
ã°ã«ã¼ãã¨å¾æ¹åç § > ã°ã«ã¼ãã¨ä¸è´çµæã®æ·»åã®ä½¿ç¨ã«è©³ãã使ç¨ä¾ãããã¾ãã
hasIndices ã®ä½¿ç¨const str1 = "foo bar foo";
const regex1 = /foo/dg;
console.log(regex1.hasIndices); // true
console.log(regex1.exec(str1).indices[0]); // [0, 3]
console.log(regex1.exec(str1).indices[0]); // [8, 11]
const str2 = "foo bar foo";
const regex2 = /foo/;
console.log(regex2.hasIndices); // false
console.log(regex2.exec(str2).indices); // undefined
仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4