SummaryThis is a cautionary tale about how I ended up writing a (bad) regular expression parser and evaluator in pure TypeScript types. type HexStr<S extends string> = Recognize<"[0-9a-fA-F]+", S>; type IsMatch<S extends string> = HexStr<S> extends S ? true : false; const isHex: IsMatch<"deadbeef"> = true const notHex: IsMatch<"nope"> = false The novelty here is parsing and evaluating regular expr
OXCã§æ£è¦è¡¨ç¾ãã¼ãµã¼ãå®è£ ãã¦ãã¨ãã«å ¨é¨ä¸éãèªãã§ã¿ã¦ãã¿ããªéã£ã¦ã¿ããªè¯ãã£ã¦ãªã£ãã®ã§ã åè£ã¯ãã¡ãã®3ã¤ã https://github.com/jviereck/regjsparser https://github.com/DmitrySoshnikov/regexp-tree https://github.com/eslint-community/regexpp ãã®AST Explorerã§ããRegExpé¨éã§ã¯ãã®3ã¤ããªã¹ãã«ããã AST explorer https://astexplorer.net/ åæ ECMAScriptæ¬ä½ã ã¨ãESTreeã¨ããããã¡ã¯ãããããã©ãæ®å¿µãªããRegExpã«ã¯ãªãã ESTreeã§ã®RegExpã®æ±ãã¯ãããªæãã§ããã ã®æååã§ãããªãã interface RegExpLiteral <: Literal
TypeScript 5.5ã§ã@graphemeclusterããã«ãã£ã¦æ£è¦è¡¨ç¾ãªãã©ã«ã®æ§æãã§ãã¯ãå°å ¥ããã¾ããð ãã®æ§æãã§ãã¯ã«ãã£ã¦ãæ£è¦è¡¨ç¾ã«ééãããã£ãå ´åãäºåã«TypeScriptãã¨ã©ã¼ãåºåãã¦ããã¾ãã ãã®æ©è½ã«ã¤ãã¦ã次ã®ãã¨ãæ°ã«ãªã£ãã®ã§èª¿ã¹ã¦ã¿ã¾ããã ã©ããªæ§æãã¨ã©ã¼ã«ãªãã ãªãå°å ¥ãããã ã©ããã£ã¦ãã§ãã¯ãã¦ããã JavaScriptã§å®è¡ã§ãããTypeScriptã§ã¨ã©ã¼ã«ãªãæ§æã¯ããã ESLintã¨ã®ã«ãã¼ç¯å²ã®éã æ¬è¨äºã«é¢ãã¦ã誤ãçãããã°ææããã ããã¨å¬ããã§ãã ã©ããªæ§æãã¨ã©ã¼ã«ãªãã TypeScript 5.5ã§ã¯ãæ£è¦è¡¨ç¾ã«é¢ããã¨ã©ã¼ã¡ãã»ã¼ã¸ã40åç¨åº¦è¿½å ããã¦ãã¾ãã ä¾ãã°ãä¸è¨ã®ãããªæ§æã¯ã5.5ã§ã¨ã©ã¼ã«ãªãã¾ãã // åå¨ããªããã©ã° var re = /a/b; // ã¨ã©ã¼
ãã®è²ã®2ã¤ã¯Unicode 15.0.0ã§å°å ¥ããããã¨ã«ä¼´ããECMAScript 2023ã§è¿½å ãããè¦è¾¼ã¿ã§ãã ãã®è²ã®5ã¤ã¯Unicode 14.0.0ã§å°å ¥ããããã¨ã«ä¼´ããECMAScript 2022ã§è¿½å ããããã®ã§ãã ãã®è²ã®4ã¤ã¯Unicode 13.0.0ã§å°å ¥ããããã¨ã«ä¼´ããECMAScript 2021ã§è¿½å ããããã®ã§ãã Hiraganaã¨Katakanaã¯ããã®ã«Kanjiããªãã¨æãããããããã¾ããããHan (Hani) ã¨ããã®ãæ¼¢åã®ãã¨ã§ãï¼ãæ¼¢åãã®ä¸å½èªèªã¿ããã¼ãååããHanziã«ç±æ¥ï¼ã Unicodeã®ãã¼ã¿ãã¡ã¤ã«ä¸ã«ã¯ææKatakana_Or_Hiragana (Hrkt) ã¨ããã¹ã¯ãªããåãåºã¦ãããã¨ãããã¾ãããããã¯åæã®é ã«ä½¿ããã¦ãããã®ã®ç¾å¨ã¯ã©ã®ã³ã¼ããã¤ã³ãã¨ãçµã³ä»ãããã¦ãã¾ããï¼UAX #44ä¸
ã¯ããã« æ£è¦è¡¨ç¾ã¯æ§ã ãªããã°ã©ãã³ã°è¨èªã§å©ç¨ããã¦ãããããã¹ãå¦çã®ããã®ãã¿ã¼ã³è¨èªã§ãã æ£è¦è¡¨ç¾ã¯ããã¹ãã¨ãã£ã¿ã§ã®æ¤ç´¢ãç½®æãå ¥åæååã®ããªãã¼ã·ã§ã³ãªã©ããã°ã©ãã³ã°ã®æ§ã ãªåéã§å®ç¨ããã¦ãã¾ãã ããç¨åº¦ã®è¦æ¨¡ã®ããã°ã©ã ã«ããã¦ãæ£è¦è¡¨ç¾ãå ¨ãå©ç¨ããªã (å©ç¨ãã¦ããªã) ã¨ãããã¨ã¯ã»ã¨ãã©ç¡ããæ£è¦è¡¨ç¾ã¯ä»æ¥ã®ããã°ã©ãã³ã°ã«ããã¦é常ã«éè¦ãªãã¼ãã ã¨è¨ãã¾ãã JavaScriptãRubyã¨ãã£ãããã°ã©ãã³ã°è¨èªã§ã¯æ£è¦è¡¨ç¾ã¯ãã¡ã¼ã¹ãã¯ã©ã¹ã®ãªãã©ã«ã¨ãã¦å®è£ ããã¦ãããããã¨ã¦ãç°¡åã«å©ç¨ã§ãã¾ãã ä¾ãã°æ¬¡ã®Rubyããã°ã©ãã³ã°ã§ã¯å¤æ°fooã«å ¥ã£ãæååã®é¨åã«fizzãbuzzãå«ã¾ãããã©ããããæ£è¦è¡¨ç¾/fizz|buzz/ã使ã£ã¦ãã§ãã¯ãã¦ãã¾ãã foo =~ /fizz|buzz/ ããã«ãè¨ç®æ©ç§å¦ (ã³ã³ãã¥ã¼ã¿ã¼ãµã¤ã¨
I first heard about regular expression denial of service (ReDoS) vulnerabilities from GitHub's Dependabot. Several of my projects over the years have had dependencies that suffered from ReDoS vulnerabilities, and I would bet that if you've built any JavaScript project with dependencies, you've also come across this. This got me thinking; if there are vulnerable regular expressions in our dependenc
The string is arguably the most essential data type in programming â every programming language and software in the world uses strings in one way or another. It enables humans to easily communicate with sophisticated programs and machines. One thing that would help you a lot as a programmer is understanding how to use and manipulate strings so that you can build programs users love. Regular expres
grex is a library that is meant to simplify the often complicated and tedious task of creating regular expressions. It does so by automatically generating a single regular expression from user-provided test cases. The resulting expression is guaranteed to match the test cases which it was generated from. This project has started as a Rust port of the JavaScript tool regexgen written by Devon Govet
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã¡ã³ããã³ã¹
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}