ã°ã«ã¼ãã¨æ£è¦è¡¨ç¾ãªãã¸ã§ã¯ã ã¢ãã«ã®è©³ç´°ã«ã¤ãã¦ã¯ãã ã°ã«ã¼ãåæ§æä½ããã³æ£è¦è¡¨ç¾ãªãã¸ã§ã¯ãããåç §ãã¦ãã ããã ä¸è´ããé¨åå¼ æ¬¡ã®ã°ã«ã¼ãåæ§æä½ã¯ãä¸è´ããé¨åå¼ããã£ããã£ãã¾ãã ( subexpression ) ããã§ãsubexpression ã¯æå¹ãªæ£è¦è¡¨ç¾ãã¿ã¼ã³ã§ãã ãã£ãã使ç¨ãããã£ããã£ã«ã¯ãæ£è¦è¡¨ç¾ã®å·¦ãã£ãã®é çªã«åºã¥ãã¦ãå·¦ããå³ã«èªåçã« 1 ããå§ã¾ãçªå·ãä»ãããã¾ãã ãã ããååä»ããã£ãã㣠ã°ã«ã¼ãã¯ã常ã«ãååãªããã£ãã㣠ã°ã«ã¼ãã®å¾ã®æå¾ã«é ç½®ããã¾ãã çªå·ã 0 ã«ãªããã£ããã£ã¯ãæ£è¦è¡¨ç¾ãã¿ã¼ã³å ¨ä½ã¨ä¸è´ããããã¹ãã§ãã ãã£ããã£ãããã°ã«ã¼ãã«ã¢ã¯ã»ã¹ããæ¹æ³ã¯ 4 ã¤ããã¾ãã æ£è¦è¡¨ç¾å ã§åæ¹åç §æ§æä½ã使ç¨ããã \number ã¨ããæ§æã使ãã¨ãä¸è´ããé¨åå¼ãåãæ£è¦è¡¨ç¾å ã§åç §ããã¾ãããã
追è¨ï¼ããããªè¨ã£ã¦ãã®æ£è¦è¡¨ç¾ã¯ãã¿ãªã®ã§ï¼å®éã«ç´ æ°å¤å®ãè¡ãããå ´åã¯ï¼ãã£ã¨å¥ãªè³¢ãã¢ã«ã´ãªãºã ã使ã£ãã»ããè¯ãã§ã æ£è¦è¡¨ç¾ã§ç´ æ°ãå¤å®ã§ããã¨ããè¨äºãè¦ãã®ã§è©¦ãã¦ã¿ãï¼ http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/ ãã®è¨äºã«ãã㨠/^1?$|^(11+?)\1+$/ ã¨ããæ£è¦è¡¨ç¾ã使ãã¨ï¼ç´ æ°å¤å®ãåºæ¥ããããï¼ããæ´æ° n ãç´ æ°ãã©ããå¤å®ãããå ´åã¯ï¼"1" * nã¨ããæååããã®æ£è¦è¡¨ç¾ã«ããããããã©ããã調ã¹ãã°ããï¼ãããããã°éç´ æ°ï¼ãããããªããã°ç´ æ°ã¨ãªãï¼ãã ãï¼"1" * n ã¯ï¼ä¾ãã°ï¼n ã 4 ãªãã° "1111" 㨠1 ã 4 åé£ç¶ãã¦ç¶ãæååã¨ãªãï¼ Rubyã§æ¸ããç´ æ°å¤å®ããã°ã©ã ã¯ãã
åå空é: System.Text.RegularExpressions ã¢ã»ã³ããª:System.Text.RegularExpressions.dll ã¢ã»ã³ããª:System.dll ã¢ã»ã³ããª:netstandard.dll éè¦ ä¸é¨ã®æ å ±ã¯ããªãªã¼ã¹åã«å¤§ããå¤æ´ãããå¯è½æ§ããããã¬ãªãªã¼ã¹ããã製åã«é¢ãããã®ã§ãã Microsoft ã¯ãããã«è¨è¼ããã¦ããæ å ±ã«ã¤ãã¦ãæ示ã¾ãã¯é»ç¤ºãåãããä¸åä¿è¨¼ãã¾ããã
æ£è¦è¡¨ç¾ã使ç¨ããã¨ãå¼·åãæè»ãããã¦å¹ççãªæ¹æ³ã§ããã¹ããå¦çã§ãã¾ãã æ£è¦è¡¨ç¾ã«ãããã¿ã¼ã³ä¸è´ã®åºç¯ãªè¡¨è¨æ³ã使ç¨ããã¨ã大éã®ããã¹ãããã°ãã解æãã次ã®ãã¨ãè¡ããã¨ãã§ãã¾ãã ç¹å®ã®æåãã¿ã¼ã³ãæ¤ç´¢ãã ããã¹ããæ¤è¨¼ãã¦ãå®ç¾©æ¸ã¿ã®ãã¿ã¼ã³ (é»åã¡ã¼ã« ã¢ãã¬ã¹ãªã©) ã¨ä¸è´ãããã¨ã確å®ã«ãã ããã¹ãé¨åæååã®æ½åºãç·¨éãç½®æãã¾ãã¯åé¤ãè¡ã æ½åºãããæååãã³ã¬ã¯ã·ã§ã³ã«è¿½å ãã¦ãã¬ãã¼ããçæãã æååå¦çã大éã®ããã¹ãã解æããå¤ãã®ã¢ããªã±ã¼ã·ã§ã³ã«ã¨ã£ã¦ãæ£è¦è¡¨ç¾ã¯æ¬ ããã¨ã®ã§ããªããã¼ã«ã§ãã æ£è¦è¡¨ç¾ã®ããã¿ æ£è¦è¡¨ç¾ã使ã£ãããã¹ãå¦çã®æãéè¦ãªé¨åã¯ã.NET ã® System.Text.RegularExpressions.Regex ãªãã¸ã§ã¯ãã«ãã£ã¦è¡¨ãããæ£è¦è¡¨ç¾ã¨ã³ã¸ã³ã§ãã æ£è¦è¡¨ç¾ã使ã£ãããã¹ãå¦çã§ã¯ãæ£è¦è¡¨
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}