{"id":2646,"date":"2025-12-08T18:08:12","date_gmt":"2025-12-08T08:38:12","guid":{"rendered":"https:\/\/softasia.jp\/blog\/?p=2646"},"modified":"2025-12-08T18:08:12","modified_gmt":"2025-12-08T08:38:12","slug":"%e3%80%90%e5%88%9d%e5%bf%83%e8%80%85%e5%bf%85%e8%a6%8b%e3%80%91python%e3%81%a7%e5%ad%a6%e3%81%b6%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e5%85%a5%e9%96%80%ef%bc%81%e3%83%86%e3%82%ad%e3%82%b9%e3%83%88","status":"publish","type":"post","link":"https:\/\/softasia.jp\/blog\/offshore\/2646\/","title":{"rendered":"\u3010\u521d\u5fc3\u8005\u5fc5\u898b\u3011Python\u3067\u5b66\u3076\u6b63\u898f\u8868\u73fe\u5165\u9580\uff01\u30c6\u30ad\u30b9\u30c8\u64cd\u4f5c\u304c\u5287\u7684\u306b\u52b9\u7387\u5316\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"size-full wp-image-2745 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT_ASIA_\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1-1000-x-1000-px-2.png\" alt=\"\" width=\"1000\" height=\"1000\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT_ASIA_\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1-1000-x-1000-px-2.png 1000w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT_ASIA_\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1-1000-x-1000-px-2-300x300.png 300w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT_ASIA_\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1-1000-x-1000-px-2-150x150.png 150w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT_ASIA_\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1-1000-x-1000-px-2-768x768.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Python\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u51e6\u7406\u3084\u5206\u6790\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u3053\u3093\u306a\u5834\u9762\u306b\u51fa\u304f\u308f\u3057\u305f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u304b\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"font-weight: 400;\"><strong>\u30c6\u30ad\u30b9\u30c8\u304b\u3089 \u6570\u5b57\u3060\u3051 \u629c\u304d\u51fa\u3057\u305f\u3044<\/strong><\/li>\n<li style=\"font-weight: 400;\"><strong>\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u96fb\u8a71\u756a\u53f7\u3092\u81ea\u52d5\u3067\u691c\u51fa\u3057\u305f\u3044<\/strong><\/li>\n<li style=\"font-weight: 400;\"><strong>CSV\u3084\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u3067\u7279\u5b9a\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u4e00\u62ec\u7f6e\u63db\u3057\u305f\u3044<\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u3046\u3057\u305f\u300c\u30d1\u30bf\u30fc\u30f3\u306b\u57fa\u3065\u3044\u305f\u6587\u5b57\u5217\u64cd\u4f5c\u300d\u3092\u52b9\u7387\u7684\u306b\u884c\u3046\u305f\u3081\u306e\u6700\u5f37\u30c4\u30fc\u30eb\u304c\u3001<strong><span style=\"color: #ff0000;\">\u6b63\u898f\u8868\u73fe\uff08Regular Expression \/ regex\uff09<\/span><\/strong> \u3067\u3059\u3002Python\u3067\u306f\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306e<span style=\"text-decoration: underline;\">re\u30e2\u30b8\u30e5\u30fc\u30eb<\/span>\u3092\u4f7f\u3048\u3070\u3001\u8ffd\u52a0\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306a\u3057\u3067\u7c21\u5358\u306b\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001\u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c\u69cb\u6587\u304b\u3089\u3001\u5b9f\u52d9\u30ec\u30d9\u30eb\u3067\u5f79\u7acb\u3064\u30c6\u30af\u30cb\u30c3\u30af\u307e\u3067\u3001\u521d\u5fc3\u8005\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u4e01\u5be7\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#i\"><span class=\"toc_number toc_depth_1\">1<\/span> \u6b63\u898f\u8868\u73fe\u3068\u306f<\/a><ul><li><a href=\"#i-2\"><span class=\"toc_number toc_depth_2\">1.1<\/span> \u6587\u5b57\u5217\u64cd\u4f5c\u306e\u300c\u9b54\u6cd5\u306e\u30eb\u30fc\u30eb\u300d<\/a><\/li><li><a href=\"#Python\"><span class=\"toc_number toc_depth_2\">1.2<\/span> Python\u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u6e96\u5099<\/a><\/li><\/ul><\/li><li><a href=\"#re\"><span class=\"toc_number toc_depth_1\">2<\/span> \u3088\u304f\u4f7f\u3046re\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u95a2\u6570\u4e00\u89a7<\/a><\/li><li><a href=\"#i-3\"><span class=\"toc_number toc_depth_1\">3<\/span> \u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c\u69cb\u6587\u307e\u3068\u3081<\/a><ul><li><a href=\"#i-4\"><span class=\"toc_number toc_depth_2\">3.1<\/span> \u5b9f\u8df5\u2460\uff1a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u62bd\u51fa\u3059\u308b<\/a><\/li><li><a href=\"#i-5\"><span class=\"toc_number toc_depth_2\">3.2<\/span> \u5b9f\u8df5\u2461\uff1a\u4e0d\u8981\u306a\u6539\u884c\u3084\u8a18\u53f7\u3092\u524a\u9664\u3059\u308b<\/a><\/li><li><a href=\"#i-6\"><span class=\"toc_number toc_depth_2\">3.3<\/span> \u5b9f\u8df5\u2462\uff1a\u8907\u6570\u306e\u6761\u4ef6\u3067\u540c\u6642\u306b\u7f6e\u63db<\/a><\/li><li><a href=\"#i-7\"><span class=\"toc_number toc_depth_2\">3.4<\/span> \u5b9f\u8df5\u2463\uff1a\u65e5\u4ed8\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u30fb\u7d71\u4e00\u3059\u308b<\/a><\/li><li><a href=\"#AI\"><span class=\"toc_number toc_depth_2\">3.5<\/span> \u5b9f\u8df5\u2464\uff1aAI\u3084\u6a5f\u68b0\u5b66\u7fd2\u306e\u524d\u51e6\u7406\u3067\u6d3b\u7528\u3059\u308b<\/a><\/li><\/ul><\/li><li><a href=\"#i-8\"><span class=\"toc_number toc_depth_1\">4<\/span> \u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u3068\u304d\u306e\u6ce8\u610f\u70b9<\/a><ul><li><a href=\"#i-9\"><span class=\"toc_number toc_depth_2\">4.1<\/span> \u30d1\u30bf\u30fc\u30f3\u304c\u8907\u96d1\u306b\u306a\u308a\u3059\u304e\u306a\u3044\u3088\u3046\u306b\u3059\u308b<\/a><\/li><li><a href=\"#rawr82218221\"><span class=\"toc_number toc_depth_2\">4.2<\/span> raw\u6587\u5b57\u5217\uff08r&#8221;\u2026&#8221;\uff09<\/a><\/li><li><a href=\"#i-10\"><span class=\"toc_number toc_depth_2\">4.3<\/span> \u6587\u5b57\u30b3\u30fc\u30c9\u306e\u7d71\u4e00<\/a><\/li><\/ul><\/li><li><a href=\"#i-11\"><span class=\"toc_number toc_depth_1\">5<\/span> \u307e\u3068\u3081<\/a><\/li><\/ul><\/div>\n<h2><span id=\"i\"><span style=\"font-weight: 400;\">\u6b63\u898f\u8868\u73fe\u3068\u306f<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-full wp-image-2651 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-46.png\" alt=\"\" width=\"640\" height=\"427\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-46.png 640w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-46-300x200.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<h3><\/h3>\n<h3><span id=\"i-2\"><span style=\"font-weight: 400;\">\u6587\u5b57\u5217\u64cd\u4f5c\u306e\u300c\u9b54\u6cd5\u306e\u30eb\u30fc\u30eb\u300d<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">\u6b63\u898f\u8868\u73fe\u3068\u306f\u3001\u6587\u5b57\u5217\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u8868\u3059\u305f\u3081\u306e\u7279\u5225\u306a\u8a18\u6cd5\u3067\u3059<\/span>\u3002\u4f8b\u3048\u3070\u3001\u6b21\u306e\u3088\u3046\u306a\u8907\u96d1\u306a\u6761\u4ef6\u3092\u308f\u305a\u304b1\u884c\u3067\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/span><span style=\"font-weight: 400;\">2\u301c4\u6841\u306e\u6570\u5b57\u306e\u3042\u3068\u306b\u30cf\u30a4\u30d5\u30f3\u304c\u7d9a\u304d\u3001\u3055\u3089\u306b\u6570\u5b57\u304c\u4e26\u3073\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u4f8b\uff1a\u96fb\u8a71\u756a\u53f7\u3092\u81ea\u52d5\u62bd\u51fa\u3059\u308b<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">import re<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;\u304a\u554f\u3044\u5408\u308f\u305b\u306f 03-1234-5678 \u307e\u3067\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">pattern = r&#8221;\\d{2,4}-\\d{2,4}-\\d{3,4}&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">result = re.findall(pattern, text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(result)\u00a0 # [&#8217;03-1234-5678&#8242;]<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">r&#8221;\\d{2,4}-\\d{2,4}-\\d{3,4}&#8221;<\/span> <span style=\"font-weight: 400;\">\u3068\u3044\u3046\u30d1\u30bf\u30fc\u30f3\u304c\u3001\u6570\u5b57\uff08<\/span>2<span style=\"font-weight: 400;\">\uff5e<\/span>4<span style=\"font-weight: 400;\">\u6841\uff09\uff0b\u30cf\u30a4\u30d5\u30f3\uff0b\u6570\u5b57\uff0b\u30cf\u30a4\u30d5\u30f3\uff0b\u6570\u5b57\u3068\u3044\u3046\u5f62\u306b\u4e00\u81f4\u3059\u308b\u90e8\u5206\u3092\u62bd\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"Python\"><span style=\"font-weight: 400;\">Python\u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u6e96\u5099<\/span><\/span><\/h3>\n<p>Python\u306e\u6b63\u898f\u8868\u73fe\u306f <span style=\"color: #ff0000;\"><strong>re\u30e2\u30b8\u30e5\u30fc\u30eb<\/strong><\/span> \u3092\u4f7f\u3044\u307e\u3059<b>\u3002<\/b><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">\u7279\u5225\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093<\/span>\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">import re<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u308c\u3060\u3051\u3067\u6e96\u5099\u5b8c\u4e86\u3067\u3059\u3002<\/span><span style=\"font-weight: 400;\">\u4ee5\u964d\u306f\u3001re \u304c\u63d0\u4f9b\u3059\u308b\u95a2\u6570\u3092\u4f7f\u3063\u3066\u691c\u7d22\u30fb\u62bd\u51fa\u30fb\u7f6e\u63db\u306a\u3069\u3092\u884c\u3044\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"re\"><span style=\"font-weight: 400;\">\u3088\u304f\u4f7f\u3046re\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u95a2\u6570\u4e00\u89a7<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-full wp-image-2654 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-47.png\" alt=\"\" width=\"640\" height=\"427\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-47.png 640w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-47-300x200.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>&nbsp;<\/p>\n<table style=\"width: 75.996446%; height: 195px;\">\n<tbody>\n<tr>\n<td style=\"width: 17.52361%;\"><b>\u95a2\u6570\u540d<\/b><\/td>\n<td style=\"width: 45.960126%;\"><b>\u6a5f\u80fd<\/b><\/td>\n<td style=\"width: 35.571878%;\"><b>\u4f8b<\/b><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 17.52361%;\"><span style=\"font-weight: 400;\">re.search()<\/span><\/td>\n<td style=\"width: 45.960126%;\"><span style=\"font-weight: 400;\">\u6700\u521d\u306b\u30de\u30c3\u30c1\u3057\u305f1\u4ef6\u3092\u8fd4\u3059<\/span><\/td>\n<td style=\"width: 35.571878%;\"><span style=\"font-weight: 400;\">re.search(r&#8221;\\d+&#8221;, text)<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 17.52361%;\"><span style=\"font-weight: 400;\">re.findall()<\/span><\/td>\n<td style=\"width: 45.960126%;\"><span style=\"font-weight: 400;\">\u3059\u3079\u3066\u306e\u4e00\u81f4\u3092\u30ea\u30b9\u30c8\u3067\u8fd4\u3059<\/span><\/td>\n<td style=\"width: 35.571878%;\"><span style=\"font-weight: 400;\">re.findall(r&#8221;\\d+&#8221;, text)<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 17.52361%;\"><span style=\"font-weight: 400;\">re.sub()<\/span><\/td>\n<td style=\"width: 45.960126%;\"><span style=\"font-weight: 400;\">\u4e00\u81f4\u90e8\u5206\u3092\u5225\u306e\u6587\u5b57\u5217\u306b\u7f6e\u63db<\/span><\/td>\n<td style=\"width: 35.571878%;\"><span style=\"font-weight: 400;\">re.sub(r&#8221;\\d&#8221;, &#8220;X&#8221;, text)<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 17.52361%;\"><span style=\"font-weight: 400;\">re.split()<\/span><\/td>\n<td style=\"width: 45.960126%;\"><span style=\"font-weight: 400;\">\u6b63\u898f\u8868\u73fe\u3067\u6587\u5b57\u5217\u3092\u5206\u5272<\/span><\/td>\n<td style=\"width: 35.571878%;\"><span style=\"font-weight: 400;\">re.split(r&#8221;[,;]&#8221;, text)<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 17.52361%;\"><span style=\"font-weight: 400;\">re.match()<\/span><\/td>\n<td style=\"width: 45.960126%;\"><span style=\"font-weight: 400;\">\u6587\u5b57\u5217\u306e\u5148\u982d\u306e\u307f\u3092\u5224\u5b9a<\/span><\/td>\n<td style=\"width: 35.571878%;\"><span style=\"font-weight: 400;\">re.match(r&#8221;\\d+&#8221;, text)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u521d\u5fc3\u8005\u306f\u307e\u305a\u3001findall() \u3068 sub() \u306e2\u3064\u3092\u30de\u30b9\u30bf\u30fc\u3057\u307e\u3057\u3087\u3046\u3002\u3053\u306e2\u3064\u3092\u899a\u3048\u308b\u3060\u3051\u3067\u3001\u30c7\u30fc\u30bf\u6574\u5f62\u30fb\u30ed\u30b0\u89e3\u6790\u30fb\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\u306e\u524d\u51e6\u7406\u304c\u5287\u7684\u306b\u697d\u306b\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-3\"><span style=\"font-weight: 400;\">\u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c\u69cb\u6587\u307e\u3068\u3081<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-full wp-image-2656 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-48.png\" alt=\"\" width=\"640\" height=\"427\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-48.png 640w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-48-300x200.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4ee5\u4e0b\u306f\u3088\u304f\u4f7f\u3046\u300c\u30e1\u30bf\u6587\u5b57\u300d\u3068\u547c\u3070\u308c\u308b\u8a18\u53f7\u4e00\u89a7\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<table style=\"width: 87.34036%; height: 550px;\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; text-align: center; height: 55px;\" valign=\"top\"><b>\u30e1\u30bf\u6587\u5b57<\/b><b><\/b><\/td>\n<td style=\"width: 38.776374%; text-align: center; height: 55px;\" valign=\"top\"><b>\u610f\u5473<\/b><b><\/b><\/td>\n<td style=\"width: 122.047409%; text-align: center; height: 55px;\" valign=\"top\"><b>\u4f8b<\/b><b><\/b><\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">.<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u4efb\u610f\u306e1\u6587\u5b57<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">a.b \u2192 a\u3068b\u306e\u9593\u306b1\u6587\u5b57<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">\\d<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u6570\u5b57\uff080\uff5e9\uff09<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">\\d+ \u2192 \u6570\u5b571\u6587\u5b57\u4ee5\u4e0a<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">\\w<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u82f1\u6570\u5b57\u3068\u30a2\u30f3\u30c0\u30fc\u30b9\u30b3\u30a2<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">\\w+ \u2192 \u5358\u8a9e<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">\\s<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u7a7a\u767d\u6587\u5b57<br \/>\n\uff08\u30b9\u30da\u30fc\u30b9\u30fb\u30bf\u30d6\u306a\u3069\uff09<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">\\s+ \u2192 1\u6587\u5b57\u4ee5\u4e0a\u306e\u7a7a\u767d<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">^<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u884c\u306e\u5148\u982d<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">^Hello \u2192 Hello\u3067\u59cb\u307e\u308b\u884c<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">$<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u884c\u306e\u672b\u5c3e<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">world$ \u2192 world\u3067\u7d42\u308f\u308b\u884c<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">[]<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u6587\u5b57\u30af\u30e9\u30b9\uff08\u3069\u308c\u304b1\u3064\uff09<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">[abc] \u2192 a\u307e\u305f\u306fb\u307e\u305f\u306fc<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">{n,m}<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">\u7e70\u308a\u8fd4\u3057\u56de\u6570<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">\\d{3,4} \u2192 3\uff5e4\u6841\u306e\u6570\u5b57<\/td>\n<\/tr>\n<tr style=\"height: 55px;\">\n<td style=\"width: 12.301517%; height: 55px; text-align: center;\" valign=\"top\">|<\/td>\n<td style=\"width: 38.776374%; height: 55px; text-align: center;\" valign=\"top\">|<\/td>\n<td style=\"width: 122.047409%; height: 55px; text-align: center;\" valign=\"top\">\u307e\u305f\u306f\uff08OR\u6761\u4ef6\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h3><span id=\"i-4\"><span style=\"font-weight: 400;\">\u5b9f\u8df5\u2460\uff1a\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u62bd\u51fa\u3059\u308b<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306e\u3088\u3046\u306b\u4e00\u5b9a\u306e\u898f\u5247\u304c\u3042\u308b\u6587\u5b57\u5217\u306f\u3001\u6b63\u898f\u8868\u73fe\u306e\u5f97\u610f\u5206\u91ce\u3067\u3059<\/span>\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;&#8221;&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u62c5\u5f53\u8005\u4e00\u89a7:<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">suzuki@example.com<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">tanaka@abc.co.jp<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">&#8220;&#8221;&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">pattern = r&#8221;[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-z]{2,}&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">emails = re.findall(pattern, text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(emails)<\/span><\/p>\n<p><span style=\"color: #0000ff;\"><span style=\"font-weight: 400;\"># [&#8216;suzuki@example.com&#8217;, &#8216;<\/span><a style=\"color: #0000ff;\" href=\"mailto:tanaka@abc.co.jp\"><span style=\"font-weight: 400;\">tanaka@abc.co.jp<\/span><\/a><span style=\"font-weight: 400;\">&#8216;]<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u3088\u3046\u306b\u3001\u8907\u96d1\u306a\u6761\u4ef6\u3067\u3082\u305f\u3063\u305f1\u884c\u306e\u30d1\u30bf\u30fc\u30f3\u3067\u62bd\u51fa\u53ef\u80fd\u3067\u3059\u3002Web\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3084\u30e1\u30fc\u30eb\u89e3\u6790\u306e\u524d\u51e6\u7406\u306b\u91cd\u5b9d\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"i-5\"><span style=\"font-weight: 400;\">\u5b9f\u8df5\u2461\uff1a\u4e0d\u8981\u306a\u6539\u884c\u3084\u8a18\u53f7\u3092\u524a\u9664\u3059\u308b<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">\u6587\u7ae0\u6574\u5f62\u306b\u304a\u3044\u3066\u3082\u3001\u6b63\u898f\u8868\u73fe\u306f\u975e\u5e38\u306b\u5fdc\u7528\u3067\u304d\u307e\u3059<\/span>\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># \u6539\u884c\u30fb\u30bf\u30d6\u3092\u524a\u9664<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;Hello\\nWorld\\tPython&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">cleaned = re.sub(r&#8221;[\\n\\t]&#8221;, &#8221; &#8220;, text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(cleaned)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># Hello World Python<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># \u8a18\u53f7\u3092\u524a\u9664<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;Hello!!! Python??? (regex)&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">cleaned = re.sub(r&#8221;[!?\\(\\)]&#8221;, &#8220;&#8221;, text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(cleaned)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># Hello Python regex<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">re.sub() \u306f replace() \u3088\u308a\u67d4\u8edf\u3067\u3001\u8907\u6570\u6761\u4ef6\u3092\u307e\u3068\u3081\u3066\u51e6\u7406\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"i-6\"><span style=\"font-weight: 400;\">\u5b9f\u8df5\u2462\uff1a\u8907\u6570\u306e\u6761\u4ef6\u3067\u540c\u6642\u306b\u7f6e\u63db<\/span><\/span><\/h3>\n<p><strong>\u4f8b\uff1a\u6570\u5b57\u3092\u3059\u3079\u3066\u300c###\u300d\u306b\u7f6e\u304d\u63db\u3048\u305f\u3044\u5834\u5408\uff1a<\/strong><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;\u4fa1\u683c\u306f1000\u5186\u3001\u9001\u6599\u306f500\u5186\u3067\u3059\u3002&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">new_text = re.sub(r&#8221;\\d+&#8221;, &#8220;###&#8221;, text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(new_text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># \u4fa1\u683c\u306f###\u5186\u3001\u9001\u6599\u306f###\u5186\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u3088\u3046\u306b\u3001 \\d+\uff08\u6570\u5b571\u6587\u5b57\u4ee5\u4e0a\uff09\u3092\u4f7f\u3048\u3070\u3001\u6841\u6570\u306b\u95a2\u4fc2\u306a\u304f\u4e00\u62ec\u7f6e\u63db\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"i-7\"><span style=\"font-weight: 400;\">\u5b9f\u8df5\u2463\uff1a\u65e5\u4ed8\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u30fb\u7d71\u4e00\u3059\u308b<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">\u30c7\u30fc\u30bf\u5206\u6790\u3067\u306f\u3001\u65e5\u4ed8\u5f62\u5f0f\u3092\u63c3\u3048\u308b\u4f5c\u696d\u304c\u3042\u308a\u3001\u6b63\u898f\u8868\u73fe\u304c\u5f79\u7acb\u3061\u307e\u3059<\/span>\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;\u672c\u65e5: 2024\/05\/01\u3001\u660e\u65e5: 2024-05-02&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">dates = re.findall(r&#8221;\\d{4}[-\/]\\d{2}[-\/]\\d{2}&#8221;, text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(dates)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># [&#8216;2024\/05\/01&#8217;, &#8216;2024-05-02&#8217;]<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u7d9a\u3044\u3066\u3001\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u7d71\u4e00\u3057\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">cleaned = [re.sub(r&#8221;\/&#8221;, &#8220;-&#8220;, date) for date in dates]<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(cleaned)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># [&#8216;2024-05-01&#8217;, &#8216;2024-05-02&#8217;]<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u308c\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3084CSV\u3078\u306e\u51fa\u529b\u304c\u30b9\u30e0\u30fc\u30ba\u306b\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"AI\"><span style=\"font-weight: 400;\">\u5b9f\u8df5\u2464\uff1aAI\u3084\u6a5f\u68b0\u5b66\u7fd2\u306e\u524d\u51e6\u7406\u3067\u6d3b\u7528\u3059\u308b<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">\u81ea\u7136\u8a00\u8a9e\u51e6\u7406\uff08NLP\uff09\u3067\u306f\u3001\u5b66\u7fd2\u524d\u306b\u4e0d\u8981\u306a\u6587\u5b57\u3092\u524a\u9664\u3059\u308b\u300c\u30af\u30ec\u30f3\u30b8\u30f3\u30b0\u300d\u304c\u6b20\u304b\u305b\u307e\u305b\u3093<\/span>\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;\u3010\u901f\u5831\u3011AI\u304c\u9032\u5316\uff01\\n\\nPython3.11\u767b\u5834\u00a0#AI #Python&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = re.sub(r&#8221;[\u3010\u3011#]&#8221;, &#8220;&#8221;, text)\u00a0 # \u7279\u5b9a\u8a18\u53f7\u524a\u9664<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = re.sub(r&#8221;\\n+&#8221;, &#8221; &#8220;, text)\u00a0 \u00a0 \u00a0 # \u6539\u884c\u3092\u30b9\u30da\u30fc\u30b9\u306b\u5909\u63db<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(text)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\"># \u901f\u5831AI\u304c\u9032\u5316\uff01 Python3.11\u767b\u5834 AI Python<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u3088\u3046\u306b\u3001\u30ce\u30a4\u30ba\u3092\u9664\u53bb\u3059\u308b\u3053\u3068\u3067\u3001\u5f62\u614b\u7d20\u89e3\u6790\u3084\u611f\u60c5\u5206\u6790\u306e\u7cbe\u5ea6\u304c\u5411\u4e0a\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-8\"><span style=\"font-weight: 400;\">\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\u3068\u304d\u306e\u6ce8\u610f\u70b9<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-full wp-image-2659 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-49.png\" alt=\"\" width=\"640\" height=\"427\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-49.png 640w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT-_ASIA-49-300x200.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"i-9\"><span style=\"font-weight: 400;\">\u30d1\u30bf\u30fc\u30f3\u304c\u8907\u96d1\u306b\u306a\u308a\u3059\u304e\u306a\u3044\u3088\u3046\u306b\u3059\u308b<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">\u6b63\u898f\u8868\u73fe\u306f\u3001\u77ed\u3044\u30b3\u30fc\u30c9\u3067\u67d4\u8edf\u306a\u691c\u7d22\u3084\u7f6e\u63db\u304c\u3067\u304d\u308b\u975e\u5e38\u306b\u5f37\u529b\u306a\u6a5f\u80fd\u3067\u3059\u304c\u3001\u4fbf\u5229\u306a\u53cd\u9762\u300c\u8aad\u307f\u3065\u3089\u3044\u300d\u300c\u5f8c\u304b\u3089\u4fee\u6b63\u3057\u306b\u304f\u3044\u300d\u3068\u3044\u3063\u305f\u554f\u984c\u3082\u8d77\u3053\u308a\u304c\u3061\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4f8b\u3048\u3070\u30011\u884c\u306b\u8907\u96d1\u306a\u30d1\u30bf\u30fc\u30f3\u3092\u8a70\u3081\u8fbc\u307f\u3059\u304e\u308b\u3068\u3001\u6570\u65e5\u5f8c\u306b\u306f\u81ea\u5206\u3067\u3082\u4f55\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u5206\u304b\u3089\u306a\u304f\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u305d\u3093\u306a\u3068\u304d\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b<\/span><strong><span style=\"color: #ff0000;\">\u30b3\u30e1\u30f3\u30c8\u4ed8\u304d\u6b63\u898f\u8868\u73fe<\/span><\/strong><span style=\"font-weight: 400;\">\u3092\u4f7f\u3046\u306e\u304c\u304a\u3059\u3059\u3081\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">import re<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">pattern = re.compile(r&#8221;&#8221;&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0^\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u884c\u982d<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0[A-Z]{3} \u00a0 \u00a0 \u00a0 # \u82f1\u5927\u6587\u5b573\u6587\u5b57<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0&#8211;\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u30cf\u30a4\u30d5\u30f3<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0\\d{4}\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u6570\u5b574\u6841<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0$\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 # \u884c\u672b<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">&#8220;&#8221;&#8221;, re.VERBOSE)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">result = re.match(pattern, &#8220;ABC-1234&#8221;)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u3088\u3046\u306b\u3001re.VERBOSE \u30d5\u30e9\u30b0\u3092\u4f7f\u3048\u3070\u3001\u6b63\u898f\u8868\u73fe\u5185\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u8a18\u8ff0\u3067\u304d\u308b\u305f\u3081\u3001 \u300c\u5f8c\u3067\u8aad\u3080\u4eba\u306b\u3082\u512a\u3057\u3044\u300d\u30b3\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u3088\u304f\u4f7f\u3046\u30d1\u30bf\u30fc\u30f3\u3092\u5909\u6570\u306b\u5207\u308a\u51fa\u3057\u3066\u304a\u304f\u3068\u3001\u53ef\u8aad\u6027\u304c\u3055\u3089\u306b\u5411\u4e0a\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"rawr82218221\"><span style=\"font-weight: 400;\">raw\u6587\u5b57\u5217\uff08r&#8221;\u2026&#8221;\uff09<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">\u6b63\u898f\u8868\u73fe\u3067\u306f\u3001\\d\uff08\u6570\u5b57\uff09\u3001\\s\uff08\u7a7a\u767d\uff09\u306a\u3069\u306e\u3088\u3046\u306b <\/span><b>\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\uff08\\\uff09<\/b><span style=\"font-weight: 400;\"> \u3092\u591a\u7528\u3057\u307e\u3059\u3002\u305f\u3060\u3057\u3001Python\u306e\u6587\u5b57\u5217\u3067\u3082 \\ \u306f\u300c\u30a8\u30b9\u30b1\u30fc\u30d7\u6587\u5b57\u300d\u3068\u3057\u3066\u4f7f\u308f\u308c\u308b\u305f\u3081\u3001\u610f\u56f3\u3057\u306a\u3044\u52d5\u4f5c\u3092\u5f15\u304d\u8d77\u3053\u3059\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u601d\u3063\u305f\u901a\u308a\u306b\u52d5\u304d\u307e\u305b\u3093\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">import re<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">text = &#8220;ID: 1234&#8221;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">result = re.search(&#8220;\\d+&#8221;, text)\u00a0 # \u3053\u308c\u306f\u8b66\u544a\u306e\u539f\u56e0\u306b\uff01<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u5834\u5408\u3001\\d \u304cPython\u306e\u30a8\u30b9\u30b1\u30fc\u30d7\u6587\u5b57\u3068\u3057\u3066\u89e3\u91c8\u3055\u308c\u3066\u3057\u307e\u3046\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002\u6b63\u3057\u304f\u306f <\/span><b>raw\u6587\u5b57\u5217<\/b><span style=\"font-weight: 400;\">\uff08\u751f\u6587\u5b57\u5217\uff09\u3092\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">result = re.search(r&#8221;\\d+&#8221;, text)\u00a0 #\u00a0 \u6b63\u3057\u3044\u66f8\u304d\u65b9<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u6587\u5b57\u5217\u306e\u524d\u306b r \u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u3001\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u3092\u300c\u305d\u306e\u307e\u307e\u306e\u6587\u5b57\u300d\u3068\u3057\u3066\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u7279\u306b\u3001\u6b63\u898f\u8868\u73fe\u3067\u306f\u5fc5\u9808\u306e\u7fd2\u6163\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"i-10\"><span style=\"font-weight: 400;\">\u6587\u5b57\u30b3\u30fc\u30c9\u306e\u7d71\u4e00<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">\u65e5\u672c\u8a9e\u3092\u542b\u3080\u30c6\u30ad\u30b9\u30c8\u3092\u6271\u3046\u5834\u5408\u3001\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\uff08\u6587\u5b57\u30b3\u30fc\u30c9\uff09\u304c\u7570\u306a\u308b\u3068\u6b63\u898f\u8868\u73fe\u304c\u3046\u307e\u304f\u6a5f\u80fd\u3057\u306a\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u7279\u306b\u3001Windows\u74b0\u5883\u3068Mac\/Linux\u74b0\u5883\u3067\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u304c\u7570\u306a\u308b\u305f\u3081\u3001\u601d\u308f\u306c\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u30b1\u30fc\u30b9\u3082\u8d77\u3053\u308a\u3048\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001<\/span><b><span style=\"color: #ff0000;\">UTF-8<\/span><\/b>\u3067\u7d71\u4e00\u3059\u308b<span style=\"font-weight: 400;\">\u306e\u304c\u6700\u3082\u5b89\u5168\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4f8b\u3048\u3070\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\u969b\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">with open(&#8220;data.txt&#8221;, &#8220;r&#8221;, encoding=&#8221;utf-8&#8243;) as f:<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0text = f.read()<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u307e\u305f\u3001\u6587\u5b57\u5217\u306e\u9014\u4e2d\u3067\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u304c\u6df7\u5728\u3057\u3066\u3044\u308b\u5834\u5408\u306f\u3001<strong><span style=\"color: #ff0000;\">str.encode() \u3084 bytes.decode()<\/span> <\/strong>\u3092\u4f7f\u3063\u3066\u6574\u3048\u3066\u304a\u304f\u3068\u5b89\u5fc3\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-11\"><span style=\"font-weight: 400;\">\u307e\u3068\u3081<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Python\u3067\u6587\u5b57\u5217\u64cd\u4f5c\u3092\u52b9\u7387\u7684\u306b\u884c\u3044\u305f\u3044\u306a\u3089\u3001\u6b63\u898f\u8868\u73fe\uff08Regular Expression\uff09 \u306f\u907f\u3051\u3066\u901a\u308c\u307e\u305b\u3093\u3002\u4e00\u898b\u96e3\u3057\u305d\u3046\u306b\u898b\u3048\u307e\u3059\u304c\u3001\u4f7f\u3044\u65b9\u3092\u30de\u30b9\u30bf\u30fc\u3059\u308c\u3070\u300c\u691c\u7d22\u30fb\u62bd\u51fa\u30fb\u7f6e\u63db\u30fb\u6574\u5f62\u300d\u306a\u3069\u306e\u4f5c\u696d\u3092\u5727\u5012\u7684\u306a\u30b9\u30d4\u30fc\u30c9\u3067\u51e6\u7406\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>\u6b63\u898f\u8868\u73fe\u3092\u7406\u89e3\u3059\u308b\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u6574\u5f62\u3084\u691c\u7d22\u51e6\u7406\u306e\u52b9\u7387\u304c\u98db\u8e8d\u7684\u306b\u5411\u4e0a\u3057\u3001\u696d\u52d9\u306e\u81ea\u52d5\u5316\u306b\u3082\u5927\u304d\u304f\u5f79\u7acb\u3061\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3082\u3057\u300c\u81ea\u793e\u306e\u30c7\u30fc\u30bf\u51e6\u7406\u3092\u81ea\u52d5\u5316\u3057\u305f\u3044\u300d\u300c\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u305f\u30ed\u30b0\u89e3\u6790\u3084\u30ec\u30dd\u30fc\u30c8\u751f\u6210\u3092\u4ed5\u7d44\u307f\u5316\u3057\u305f\u3044\u300d\u3068\u3044\u3063\u305f\u5b9f\u8df5\u7684\u306a\u8ab2\u984c\u304c\u3042\u308c\u3070\u3001\u305c\u3072\u304a\u6c17\u8efd\u306b<span style=\"color: #0000ff;\"><a style=\"color: #0000ff;\" href=\"https:\/\/softasia.jp\/#contact\"><em><strong>3ink<\/strong><\/em><\/a><\/span>\u3054\u76f8\u8ac7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3042\u306a\u305f\u306e\u696d\u52d9\u5185\u5bb9\u306b\u5408\u308f\u305b\u3066\u3001\u6700\u9069\u306aPython\u30b9\u30af\u30ea\u30d7\u30c8\u3084\u5206\u6790\u30c4\u30fc\u30eb\u306e\u958b\u767a\u3092\u3054\u63d0\u6848\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n<p><br style=\"font-weight: 400;\" \/><br style=\"font-weight: 400;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Python\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u51e6\u7406\u3084\u5206\u6790\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u3053\u3093\u306a\u5834\u9762\u306b\u51fa\u304f\u308f\u3057\u305f\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u304b\u3002 &nbsp; \u30c6\u30ad\u30b9\u30c8\u304b\u3089 \u6570\u5b57\u3060\u3051 \u629c\u304d\u51fa\u3057\u305f\u3044 \u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u96fb\u8a71\u756a\u53f7\u3092\u81ea\u52d5\u3067\u691c\u51fa\u3057\u305f\u3044 CSV\u3084\u30ed\u30b0\u30d5\u30a1 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":2745,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[4,1,9],"tags":[],"jetpack_featured_media_url":"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/10\/SOFT_ASIA_\u30a2\u30a4\u30ad\u30e3\u30c3\u30c1-1000-x-1000-px-2.png","_links":{"self":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts\/2646"}],"collection":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/comments?post=2646"}],"version-history":[{"count":38,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts\/2646\/revisions"}],"predecessor-version":[{"id":2725,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts\/2646\/revisions\/2725"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/media\/2745"}],"wp:attachment":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/media?parent=2646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/categories?post=2646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/tags?post=2646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}