{"id":3413,"date":"2025-07-10T10:53:08","date_gmt":"2025-07-10T01:53:08","guid":{"rendered":"https:\/\/meister-kentei.jp\/magazine\/?p=3413"},"modified":"2025-07-10T11:06:42","modified_gmt":"2025-07-10T02:06:42","slug":"%e3%80%90java%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%80%91%e7%b5%84%e3%81%bf%e5%90%88%e3%82%8f%e3%81%9b%e3%82%84%e4%bd%bf%e3%81%84%e6%96%b9%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81","status":"publish","type":"post","link":"https:\/\/meister-kentei.jp\/magazine\/programming\/3413\/","title":{"rendered":"\u3010Java\u6b63\u898f\u8868\u73fe\u3011\u7d44\u307f\u5408\u308f\u305b\u3084\u4f7f\u3044\u65b9\u306e\u307e\u3068\u3081"},"content":{"rendered":"<div id=\"toc_container\" class=\"toc_white no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#Java\"><span class=\"toc_number toc_depth_1\">1<\/span> Java\u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c<\/a><ul><li><a href=\"#Java-2\"><span class=\"toc_number toc_depth_2\">1.1<\/span> Java\u6b63\u898f\u8868\u73fe\u3068\u306f<\/a><\/li><li><a href=\"#PatternMatcher\"><span class=\"toc_number toc_depth_2\">1.2<\/span> Pattern\u30af\u30e9\u30b9\u3068Matcher\u30af\u30e9\u30b9<\/a><\/li><li><a href=\"#Java-3\"><span class=\"toc_number toc_depth_2\">1.3<\/span> Java\u6b63\u898f\u8868\u73fe\u3067\u3067\u304d\u308b\u3053\u3068<\/a><\/li><\/ul><\/li><li><a href=\"#Java-4\"><span class=\"toc_number toc_depth_1\">2<\/span> Java\u6b63\u898f\u8868\u73fe\u306e\u7d44\u307f\u5408\u308f\u305b<\/a><ul><li><a href=\"#i\"><span class=\"toc_number toc_depth_2\">2.1<\/span> \u3059\u3079\u3066\u306e\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408<\/a><\/li><li><a href=\"#i-2\"><span class=\"toc_number toc_depth_2\">2.2<\/span> \u3069\u308c\u304b\u3072\u3068\u3064\u306e\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408<\/a><\/li><\/ul><\/li><li><a href=\"#Java-5\"><span class=\"toc_number toc_depth_1\">3<\/span> Java\u6b63\u898f\u8868\u73fe\u306e\u4f7f\u3044\u65b9<\/a><ul><li><a href=\"#Pattern\"><span class=\"toc_number toc_depth_2\">3.1<\/span> Pattern\u3092\u4f5c\u308b<\/a><\/li><li><a href=\"#matches\"><span class=\"toc_number toc_depth_2\">3.2<\/span> matches\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046<\/a><\/li><\/ul><\/li><li><a href=\"#Java-6\"><span class=\"toc_number toc_depth_1\">4<\/span> Java\u6b63\u898f\u8868\u73fe\u306e\u6d3b\u7528\u4f8b<\/a><ul><li><a href=\"#i-3\"><span class=\"toc_number toc_depth_2\">4.1<\/span> \u82f1\u6570\u5b57\u3084\u65e5\u4ed8\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/a><\/li><li><a href=\"#i-4\"><span class=\"toc_number toc_depth_2\">4.2<\/span> \u6587\u5b57\u5217\u306e\u64cd\u4f5c\u3092\u884c\u3046<\/a><\/li><\/ul><\/li><li><a href=\"#Java-7\"><span class=\"toc_number toc_depth_1\">5<\/span> Java\u3092\u5b66\u3076\u306a\u3089\u30a6\u30ba\u30a6\u30ba\u30ab\u30ec\u30c3\u30b8<\/a><\/li><li><a href=\"#Java-8\"><span class=\"toc_number toc_depth_1\">6<\/span> \u3010\u307e\u3068\u3081\u3011Java\u6b63\u898f\u8868\u73fe\u3092\u7406\u89e3\u3057\u3066\u6d3b\u7528\u3057\u3088\u3046\uff01<\/a><\/li><\/ul><\/div>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u304a\u3044\u3066\u3001\u65e5\u4ed8\u3084\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306a\u3069\u3001\u540c\u3058\u3088\u3046\u306a\u6587\u5b57\u5217\u306b\u5bfe\u3057\u3066\u540c\u69d8\u306e\u51e6\u7406\u3092\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u304c\u826f\u304f\u3042\u308a\u307e\u3059\u3002<br \/>\n\u305d\u3093\u306a\u6642\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u5074\u306b\u691c\u7d22\u3057\u305f\u3044\u6587\u5b57\u5217\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u6559\u3048\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<br \/>\n\u305d\u306e\u969b\u4f7f\u3046\u306e\u304c\u3001<span class=\"marker\">\u300c\u6b63\u898f\u8868\u73fe\u300d<\/span>\u3068\u3044\u3046\u8a18\u8ff0\u65b9\u6cd5\u3067\u3059\u3002<br \/>\n\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001Java\u306e\u6b63\u898f\u8868\u73fe\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2><span id=\"Java\">Java\u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c<\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3418\" src=\"https:\/\/meister-kentei.jp\/magazine\/wp-content\/uploads\/2022\/09\/security-g6dcf04b37_1920.jpg\" alt=\"\" width=\"1920\" height=\"1203\" \/>\u6b63\u898f\u8868\u73fe\u3068\u306f\u3001\u6587\u5b57\u5217\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u304c\u5206\u304b\u308b\u5f62\u5f0f\u3067\u8a18\u8ff0\u3057\u305f\u8868\u73fe\u306e\u3053\u3068\u3067\u3059\u3002<br \/>\n\u6b63\u898f\u8868\u73fe\u81ea\u4f53\u306f\u591a\u304f\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u4eca\u56de\u306fJava\u306e\u6b63\u898f\u8868\u73fe\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h3><span id=\"Java-2\">Java\u6b63\u898f\u8868\u73fe\u3068\u306f<\/span><\/h3>\n<p>\u6b63\u898f\u8868\u73fe\u3068\u306f\u3001<span class=\"marker\">\u300c\u6587\u5b57\u5217\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u304c\u5206\u304b\u308b\u5f62\u5f0f\u3067\u8a18\u8ff0\u3057\u305f\u8868\u73fe\u300d<\/span>\u306e\u3053\u3068\u3067\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u591a\u304f\u306e\u6587\u5b57\u5217\u306e\u4e2d\u304b\u3089\u300c\u90f5\u4fbf\u756a\u53f7\u300d\u3060\u3051\u3092\u691c\u7d22\u3057\u305f\u3044\u5834\u5408\u3001\u6b21\u306e\u3088\u3046\u306a\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>[0-9]{3}-[0-9]{4}\r\n<\/pre>\n<\/div>\n<\/div>\n<p>\u3053\u3061\u3089\u306f\u3001\u300c\u300c0-9\u306e\u6570\u5b57\u4e09\u6841\u300d-(\u30cf\u30a4\u30d5\u30f3)\u300c0-9\u306e\u6570\u5b574\u6841\u300d\u300d\u3068\u3044\u3046\u30d1\u30bf\u30fc\u30f3\u3092\u8868\u73fe\u3059\u308b\u6b63\u898f\u8868\u73fe\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u3066\u3001\u6587\u5b57\u5217\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u898f\u5247\u7684\u306b\u8868\u73fe\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u304c\u691c\u7d22\u7b49\u306e\u51e6\u7406\u3092\u884c\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"PatternMatcher\">Pattern\u30af\u30e9\u30b9\u3068Matcher\u30af\u30e9\u30b9<\/span><\/h3>\n<p>Java\u3067\u6b63\u898f\u8868\u73fe\u3092\u5229\u7528\u3057\u305f\u3044\u6642\u306f\u3001<span class=\"marker\">\u300cPattern\u30af\u30e9\u30b9\u300d<\/span>\u3068<span class=\"marker\">\u300cMatcher\u30af\u30e9\u30b9\u300d<\/span>\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n\u300cPattern\u30af\u30e9\u30b9\u300d\u306f\u6b63\u898f\u8868\u73fe\u306e\u300c\u30d1\u30bf\u30fc\u30f3\u300d\u3092\u3001\u300cMatcher\u30af\u30e9\u30b9\u300d\u306f\u6b63\u898f\u8868\u73fe\u3068\u691c\u7d22\u3057\u305f\u3044\u6587\u5b57\u5217\u3068\u306e\u300c\u30de\u30c3\u30c1\u30f3\u30b0\u300d\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>Java\u6b63\u898f\u8868\u73fe\u306f\u3001\u57fa\u672c\u7684\u306b\u306f\u3053\u306ePattern\u3068Matcher\u3092\u5229\u7528\u3057\u307e\u3059\u304c\u3001\u305d\u308c\u4ee5\u5916\u306b\u3082matches\u30e1\u30bd\u30c3\u30c9\u3082\u5229\u7528\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4e21\u8005\u306e\u8a73\u3057\u3044\u4f7f\u3044\u65b9\u306f\u5f8c\u307b\u3069\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"Java-3\">Java\u6b63\u898f\u8868\u73fe\u3067\u3067\u304d\u308b\u3053\u3068<\/span><\/h3>\n<p>Java\u6b63\u898f\u8868\u73fe\u3092\u5229\u7528\u3059\u308c\u3070\u3001\u691c\u7d22\u4ee5\u5916\u306b\u3082\u69d8\u3005\u306a\u51e6\u7406\u304c\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u300cYellow, Red, Black\u300d\u3068\u3044\u3063\u305f\u6587\u5b57\u5217\u3092\u300c,\u300d\u3067\u533a\u5207\u3063\u3066<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>Yellow\r\nRed\r\nBlack<\/pre>\n<\/div>\n<\/div>\n<p>\u3068\u51fa\u529b\u3057\u305f\u308a\u3001\u6b63\u898f\u8868\u73fe\u306b\u30de\u30c3\u30c1\u3057\u305f\u6587\u5b57\u5217\u3092\u7f6e\u63db\u30fb\u9664\u53bb\u3057\u305f\u308a\u3068\u3001\u69d8\u3005\u306a\u4f7f\u3044\u65b9\u304c\u53ef\u80fd\u3067\u3059\u3002<br \/>\n\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3044\u3053\u306a\u3059\u3053\u3068\u3067\u3001\u6587\u5b57\u5217\u3092\u6271\u3048\u308b\u5e45\u304c\u5927\u304d\u304f\u5e83\u304c\u308a\u307e\u3059\u3002<br \/>\n\u4f7f\u3044\u65b9\u3092\u30de\u30b9\u30bf\u30fc\u3057\u3066\u3001\u30b9\u30ad\u30eb\u30a2\u30c3\u30d7\u3092\u76ee\u6307\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>Java\u306e\u57fa\u672c\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3082\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a href=\"https:\/\/meister-kentei.jp\/magazine\/programming\/3170\/\">\u3010Java\u5165\u9580\u7de8\u3011\u7279\u5fb4\u3068\u3067\u304d\u308b\u3053\u3068\u3001\u7fd2\u5f97\u306e\u30e1\u30ea\u30c3\u30c8\u3092\u89e3\u8aac\uff01<\/a><\/p>\n<h2><span id=\"Java-4\">Java\u6b63\u898f\u8868\u73fe\u306e\u7d44\u307f\u5408\u308f\u305b<\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3419\" src=\"https:\/\/meister-kentei.jp\/magazine\/wp-content\/uploads\/2022\/09\/spyware-g49042f775_1280.jpg\" alt=\"\" width=\"1280\" height=\"853\" \/>Java\u3067\u306f\u3001<span class=\"marker\">\u8907\u6570\u306e\u6b63\u898f\u8868\u73fe\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u5229\u7528\u3059\u308b<\/span>\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<br \/>\n\u300c\u30d1\u30bf\u30fc\u30f3A\u306b\u30de\u30c3\u30c1\u3059\u308b\u300d\u304b\u3064\u300c\u30d1\u30bf\u30fc\u30f3B\u306b\u30de\u30c3\u30c1\u3059\u308b\u300d<br \/>\n\u300c\u30d1\u30bf\u30fc\u30f3A\u306b\u30de\u30c3\u30c1\u3059\u308b\u300d\u3042\u308b\u3044\u306f\u300c\u30d1\u30bf\u30fc\u30f3B\u306b\u30de\u30c3\u30c1\u3059\u308b\u300d<br \/>\n\u3068\u3044\u3063\u305f\u5177\u5408\u306b\u3001\u8907\u6570\u306e\u6b63\u898f\u8868\u73fe\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3088\u308a\u67d4\u8edf\u306a\u691c\u7d22\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3><span id=\"i\">\u3059\u3079\u3066\u306e\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408<\/span><\/h3>\n<p>\u307e\u305a\u3001\u3059\u3079\u3066\u306e\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408\u306e\u8a18\u8ff0\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\u5168\u3066\u306e\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u7d44\u307f\u5408\u308f\u305b(and)\u306f\u3001<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre><strong>\u6761\u4ef61*\u6761\u4ef62<\/strong><\/pre>\n<\/div>\n<\/div>\n<p>\u3068\u8868\u73fe\u3057\u307e\u3059\u3002\u300c*\u300d\u3067\u8907\u6570\u306e\u6761\u4ef6\u3092\u3064\u306a\u304e\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u300c0\u304b\u3089\u59cb\u307e\u308b\u300d\u3068\u3044\u3046\u6761\u4ef6\u3068\u300c9\u3067\u7d42\u308f\u308b\u300d\u3068\u3044\u3046\u6761\u4ef6\u306e\u4e21\u65b9\u306b\u4e00\u81f4\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u3092\u691c\u7d22\u3059\u308b\u969b\u306f\u3001\u6b21\u306e\u3088\u3046\u306a\u6b63\u898f\u8868\u73fe\u3092\u7528\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>^1*9$<\/pre>\n<\/div>\n<\/div>\n<h3><span id=\"i-2\">\u3069\u308c\u304b\u3072\u3068\u3064\u306e\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408<\/span><\/h3>\n<p>\u8907\u6570\u306e\u6761\u4ef6\u306e\u5185\u3069\u308c\u304b\u4e00\u3064\u306b\u4e00\u81f4\u3059\u308b\u5834\u5408\u306e\u8a18\u8ff0\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\u3069\u308c\u304b\u4e00\u3064\u306b\u4e00\u81f4\u3059\u308b\u7d44\u307f\u5408\u308f\u305b(or)\u306f\u3001<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre><strong>\u6761\u4ef61|\u6761\u4ef62<\/strong><\/pre>\n<\/div>\n<\/div>\n<p>\u3068\u8868\u73fe\u3057\u307e\u3059\u3002\u300c|\u300d\u3067\u8907\u6570\u306e\u6761\u4ef6\u3092\u3064\u306a\u304e\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u300c0\u304b\u3089\u59cb\u307e\u308b\u300d\u3068\u3044\u3046\u6761\u4ef6\u3068\u300c9\u3067\u7d42\u308f\u308b\u300d\u3068\u3044\u3046\u6761\u4ef6\u306e\u4e00\u65b9\u306b\u4e00\u81f4\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u3092\u691c\u7d22\u3059\u308b\u969b\u306f\u3001\u6b21\u306e\u3088\u3046\u306a\u6b63\u898f\u8868\u73fe\u3092\u7528\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>^1|9$<\/pre>\n<\/div>\n<\/div>\n<h2><span id=\"Java-5\">Java\u6b63\u898f\u8868\u73fe\u306e\u4f7f\u3044\u65b9<\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3420\" src=\"https:\/\/meister-kentei.jp\/magazine\/wp-content\/uploads\/2022\/09\/desk-ge977e1b5e_1920.jpg\" alt=\"\" width=\"1920\" height=\"1280\" \/>\u305d\u308c\u3067\u306f\u3001Java\u6b63\u898f\u8868\u73fe\u306e\u5177\u4f53\u7684\u306a\u4f7f\u3044\u65b9\u3092\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u305f\u691c\u7d22\u306e\u65b9\u6cd5\u306f\u4e3b\u306b2\u3064\u3042\u308a\u307e\u3059\u3002<br \/>\n1\u3064\u306f\u300cPattern\u300d\u30af\u30e9\u30b9\u3092\u4f5c\u308b\u65b9\u6cd5\u3001\u3082\u30461\u3064\u306f\u300cmatches\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<h3><span id=\"Pattern\">Pattern\u3092\u4f5c\u308b<\/span><\/h3>\n<p>\u307e\u305a\u306f\u3001<span class=\"marker\">Pattern\u30af\u30e9\u30b9\u3092\u4f5c\u308a\u3001Matches\u30af\u30e9\u30b9\u3067\u7167\u5408\u3059\u308b<\/span>\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u3001\u30b3\u30fc\u30c9\u4f8b\u3067\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>import java.util.regex.Matcher;\r\nimport java.util.regex.Pattern;\r\n\r\npublic class Main {\r\n\u3000\u3000public static void main(String[] args) {\r\n\r\n\u3000\u3000\u3000\u3000String str = \"100-0000 \u6771\u4eac\u90fd\u5343\u4ee3\u7530\u533a\";\r\n\r\n\u3000\u3000\u3000\u3000Pattern p = Pattern.compile(\"[0-9]{3}-[0-9]{4}\");\r\n\u3000\u3000\u3000\u3000Matcher m = p.matcher(str);\r\n\r\n\u3000\u3000\u3000\u3000System.out.println(m.find());\r\n\u3000\u3000}\r\n}<\/pre>\n<\/div>\n<\/div>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u691c\u7d22\u3057\u305f\u3044\u6587\u5b57\u5217\u3068\u3057\u3066\u300c100-0000 \u6771\u4eac\u90fd\u5343\u4ee3\u7530\u533a\u300d\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>Pattern p = Pattern.compile(\"[0-9]{3}-[0-9]{4}\");<\/pre>\n<\/div>\n<\/div>\n<p>\u3067\u3001\u6b63\u898f\u8868\u73fe\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>Matcher m = p.matcher(str);<\/pre>\n<\/div>\n<\/div>\n<p>\u3067\u3001\u300cPattern\u300d\u3067\u6307\u5b9a\u3055\u308c\u305f\u6b63\u898f\u8868\u73fe\u3068\u6587\u5b57\u5217(str)\u3068\u306e\u30de\u30c3\u30c1\u30f3\u30b0\u3092\u884c\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306e\u5834\u5408\u3001\u6587\u5b57\u5217\u306e\u4e2d\u306b\u300c100-0000\u300d\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u5b9f\u884c\u7d50\u679c\u3068\u3057\u3066\u306f\u300ctrue\u300d\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u300cPattern\u30af\u30e9\u30b9\u300d\u3068\u300cMatcher\u30af\u30e9\u30b9\u300d\u3092\u5229\u7528\u3057\u3066\u6b63\u898f\u8868\u73fe\u3067\u306e\u691c\u7d22\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3><span id=\"matches\">matches\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046<\/span><\/h3>\n<p>\u5358\u7d14\u306b\u691c\u7d22\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306f\u3001\u308f\u3056\u308f\u3056\u300cPattern\u30af\u30e9\u30b9\u300d\u3068\u300cMatcher\u30af\u30e9\u30b9\u300d\u3092\u4f7f\u308f\u305a\u3068\u3082\u3001<span class=\"marker\">\u300cmatches\u300d\u30e1\u30bd\u30c3\u30c9<\/span>\u3067\u7c21\u5358\u306b\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u3001\u30b3\u30fc\u30c9\u4f8b\u3067\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>public class Main {\r\n\r\n\u3000\u3000public static void main(String[] args) throws Exception {\r\n\r\n\u3000\u3000\u3000\u3000String str = \"redblackbluewhite\";\r\n\r\n\u3000\u3000\u3000\u3000if(str.matches(\".*blue.*\"))\r\n\u3000\u3000\u3000\u3000{\r\n\u3000\u3000\u3000\u3000\u3000\u3000System.out.println(\"blue matched\");\r\n\u3000\u3000\u3000\u3000}\r\n\u3000\u3000}\r\n}<\/pre>\n<\/div>\n<\/div>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u6587\u5b57\u5217\u300credblackbluewhite\u300d\u3092\u691c\u7d22\u5bfe\u8c61\u3068\u3057\u3001\u6587\u5b57\u5217\u5185\u306b\u300cblue\u300d\u304c\u542b\u307e\u308c\u308b\u30d1\u30bf\u30fc\u30f3\u3092\u6b63\u898f\u8868\u73fe\u3067\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nmatches\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u300cPattern\u300d\u300cMatcher\u300d\u30af\u30e9\u30b9\u3092\u4f7f\u308f\u305a\u3068\u3082\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u3066\u691c\u7d22\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2><span id=\"Java-6\">Java\u6b63\u898f\u8868\u73fe\u306e\u6d3b\u7528\u4f8b<\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3421\" src=\"https:\/\/meister-kentei.jp\/magazine\/wp-content\/uploads\/2022\/09\/office-g61bdb6c88_1920.jpg\" alt=\"\" width=\"1920\" height=\"1275\" \/>Java\u6b63\u898f\u8868\u73fe\u306e\u6d3b\u7528\u4f8b\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\nJava\u6b63\u898f\u8868\u73fe\u306f\u3001\u69d8\u3005\u306a\u51e6\u7406\u306b\u5229\u7528\u3067\u304d\u307e\u3059\u304c\u3001\u3053\u3053\u3067\u306f2\u3064\u306e\u6d3b\u7528\u4f8b\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h3><span id=\"i-3\">\u82f1\u6570\u5b57\u3084\u65e5\u4ed8\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b<\/span><\/h3>\n<p>\u3042\u308b\u6587\u5b57\u5217\u304c\u82f1\u6570\u5b57\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u3088\u3046\u306a\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>^[0-9a-zA-Z]+$<\/pre>\n<\/div>\n<\/div>\n<p>\u300c0-9\u306e\u6570\u5b57\u3001a-z\u306e\u82f1\u5c0f\u6587\u5b57\u3001A-Z\u306e\u82f1\u5927\u6587\u5b57\u300d\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u30d1\u30bf\u30fc\u30f3\u3092\u8868\u73fe\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u300c2022\/01\/01\u300d\u3068\u3044\u3063\u305f\u65e5\u4ed8\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u969b\u306b\u306f\u3001\u6b21\u306e\u3088\u3046\u306a\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>^[0-9]{4}\/[0-9]{2}\/[0-9]{2}$<\/pre>\n<\/div>\n<\/div>\n<p>\u300co-9\u306e\u6570\u5b574\u6841\/\u6570\u5b572\u6841\/\u6570\u5b572\u6841\u300d\u3067\u69cb\u6210\u3055\u308c\u3066\u3044\u308b\u30d1\u30bf\u30fc\u30f3\u3092\u8868\u73fe\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3><span id=\"i-4\">\u6587\u5b57\u5217\u306e\u64cd\u4f5c\u3092\u884c\u3046<\/span><\/h3>\n<p>\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3063\u3066\u3001\u6587\u5b57\u5217\u306e\u64cd\u4f5c\u3092\u884c\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u306f\u3001<span class=\"marker\">\u6587\u5b57\u5217\u306e\u7f6e\u304d\u63db\u3048\u3068\u9664\u53bb<\/span>\u306e\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<p>\u6587\u5b57\u5217\u306e\u7f6e\u304d\u63db\u3048\u306f\u3001\u6b21\u306e\u3088\u3046\u306b\u300cMatcher\u300d\u30af\u30e9\u30b9\u306e\u300creplaceAll\u300d\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>Pattern pattern = Pattern.compile(\"[a-z]+\");\r\n\r\nMatcher matcher1 = pattern.matcher(\"abc def\");\r\nString replaced1 = matcher1.replaceAll(\"123\");\r\nSystem.out.println(replaced1);<\/pre>\n<\/div>\n<\/div>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u300c\u82f1\u6587\u5b57\u300d\u306b\u4e00\u81f4\u3059\u308b\u6587\u5b57\u5217\u3092\u5168\u3066\u300c123\u300d\u306b\u7f6e\u304d\u63db\u3048\u308b\u30b3\u30fc\u30c9\u3067\u3059\u3002<br \/>\n\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u300c123 123\u300d\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u6587\u5b57\u5217\u3092\u9664\u53bb\u3059\u308b\u969b\u306b\u306f\u3001\u6b21\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<div class=\"single__box-secondary\">\n<div>\n<pre>String s = \"a b c d\";\r\nPattern p = Pattern.compile(\" \");\r\nMatcher m = p.matcher(s);\r\nString r = m.replaceAll(\"\");\r\nSystem.out.println(r);<\/pre>\n<\/div>\n<\/div>\n<p>\u6587\u5b57\u5217\u300ca b c d\u300d\u306e\u9593\u306b\u542b\u307e\u308c\u308b\u300c&#8221; &#8220;\u300d(\u534a\u89d2\u30b9\u30da\u30fc\u30b9)\u3092\u3001\u300c\u201d\u201d\u300d\u306b\u7f6e\u63db\u3059\u308b\u3053\u3068\u3067\u3001\u534a\u89d2\u30b9\u30da\u30fc\u30b9\u3092\u9664\u53bb\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u300cabcd\u300d\u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2><span id=\"Java-7\">Java\u3092\u5b66\u3076\u306a\u3089\u30a6\u30ba\u30a6\u30ba\u30ab\u30ec\u30c3\u30b8<\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/meister-kentei.jp\/magazine\/wp-content\/uploads\/2024\/08\/IMG_3937.jpeg\" alt=\"\" width=\"2202\" height=\"1179\" class=\"alignnone size-full wp-image-7339\" \/><\/p>\n<p>\u30a6\u30ba\u30a6\u30ba\u30ab\u30ec\u30c3\u30b8Java\u30b3\u30fc\u30b9\u306f\u3001Java\u30b7\u30eb\u30d0\u30fc\u53d6\u5f97\u3092\u3057\u958b\u767a\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306e\u5c31\u8077\u3001\u30ad\u30e3\u30ea\u30a2\u30a2\u30c3\u30d7\u3092\u76ee\u6307\u3059\u30b3\u30fc\u30b9\u3067\u3059\u3002<br \/>\nJava\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3001\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306a\u3069\u3092\u5b66\u7fd2\u3057\u307e\u3059\u3002<span class=\"marker\">\u6559\u6750\u304c\u3059\u3079\u3066\u52d5\u753b\u5316\u3001\u6f14\u7fd2\u3082\uff45\u30e9\u30fc\u30cb\u30f3\u30b0\u3067\u5b8c\u7d50\u3059\u308b\u305f\u3081\u53d7\u8b1b\u751f\u306e\u90fd\u5408\u306b\u5408\u308f\u305b\u305f\u30aa\u30fc\u30c0\u30fc\u30e1\u30a4\u30c9\u578b\u5b66\u7fd2\u304c\u53ef\u80fd<\/span>\u3067\u3059\u3002<br \/>\n\u4e00\u4eba\u4e00\u4eba\u306b\u5fc5\u305a\u62c5\u4efb\u8b1b\u5e2b\u304c\u3064\u304f\u306e\u3067\u632b\u6298\u306e\u5fc3\u914d\u3082\u306a\u304f\u3001\u5c31\u8077\u3084\u8ee2\u8077\u306e\u30b5\u30dd\u30fc\u30c8\u3082\u3057\u3063\u304b\u308a\u3068\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u5fc3\u5f37\u3044\u3067\u3059\u3002<br \/>\n\u307e\u305f\u30ea\u30b9\u30ad\u30ea\u30f3\u30b0\u3092\u901a\u3058\u305f\u30ad\u30e3\u30ea\u30a2\u30a2\u30c3\u30d7\u652f\u63f4\u4e8b\u696d\uff08\u7d4c\u6e08\u7523\u696d\u7701\uff09\u306e\u5bfe\u8c61\u3068\u306a\u308bIT\u8ee2\u8077\u652f\u63f4\u30b5\u30fc\u30d3\u30b9\u306e\u305f\u3081\u3001IT\u5b66\u7fd2\u652f\u63f4\u306b\u304b\u304b\u308b\u8cbb\u7528\u306e<span class=\"marker\">\u6700\u592770%\u306e\u88dc\u52a9\u91d1\u3092\u53d7\u3051\u53d6\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/span><br \/>\n\u7121\u6599\u30ab\u30a6\u30f3\u30bb\u30ea\u30f3\u30b0\u3082\u3042\u308b\u306e\u3067\u3001\u6c17\u306b\u306a\u3063\u305f\u65b9\u306f\u4e00\u5ea6\u53d7\u3051\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><a class=\"btn__single\" href=\"https:\/\/af.moshimo.com\/af\/c\/click?a_id=5094928&#038;p_id=6813&#038;pc_id=19496&#038;pl_id=87476\" target=\"_blank\" rel=\"nofollow noopener\">\u30a6\u30ba\u30a6\u30ba\u30ab\u30ec\u30c3\u30b8\u3000\u516c\u5f0f\u30b5\u30a4\u30c8<\/a><\/p>\n<h2><span id=\"Java-8\">\u3010\u307e\u3068\u3081\u3011Java\u6b63\u898f\u8868\u73fe\u3092\u7406\u89e3\u3057\u3066\u6d3b\u7528\u3057\u3088\u3046\uff01<\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3422\" src=\"https:\/\/meister-kentei.jp\/magazine\/wp-content\/uploads\/2022\/09\/computer-g6c16b987f_1920.png\" alt=\"\" width=\"1920\" height=\"1054\" \/>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001Java\u6b63\u898f\u8868\u73fe\u306e\u4f7f\u3044\u65b9\u3092\u89e3\u8aac\u3057\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\nJava\u6b63\u898f\u8868\u73fe\u306f\u3001\u57fa\u672c\u7684\u306b\u306f\u300cPattern\u30af\u30e9\u30b9\u300d\u3068\u300cMatcher\u30af\u30e9\u30b9\u300d\u3092\u4f7f\u3063\u3066\u8868\u73fe\u3057\u307e\u3059\u3002<br \/>\n\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3048\u3070\u3001\u691c\u7d22\u3060\u3051\u3067\u306a\u304f\u7f6e\u63db\u3084\u9664\u53bb\u306a\u3069\u3001\u69d8\u3005\u306a\u51e6\u7406\u3092\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Java\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3044\u3053\u306a\u3057\u3066\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30ad\u30eb\u5411\u4e0a\u3092\u76ee\u6307\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>Java\u306b\u3064\u3044\u3066\u306f\u3001\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3082\u5408\u308f\u305b\u3066\u3054\u89a7\u304f\u3060\u3055\u3044<\/p>\n<p><a href=\"https:\/\/meister-kentei.jp\/magazine\/programming\/3130\/\">Java\u306e\u914d\u5217\u3068\u306f\uff1f\u57fa\u672c\u304b\u3089\u5fdc\u7528\u307e\u3067\u4f7f\u3044\u65b9\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac<\/a><br \/>\n<a href=\"https:\/\/meister-kentei.jp\/magazine\/programming\/3170\/\">\u3010Java\u5165\u9580\u7de8\u3011\u7279\u5fb4\u3068\u3067\u304d\u308b\u3053\u3068\u3001\u7fd2\u5f97\u306e\u30e1\u30ea\u30c3\u30c8\u3092\u89e3\u8aac\uff01<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b211 Java\u6b63\u898f\u8868\u73fe\u306e\u57fa\u672c1.1 Java\u6b63\u898f\u8868\u73fe\u3068\u306f1.2 Pattern\u30af\u30e9\u30b9\u3068Matcher\u30af\u30e9\u30b91.3 Java\u6b63\u898f\u8868\u73fe\u3067\u3067\u304d\u308b\u3053\u30682 Java\u6b63\u898f\u8868\u73fe\u306e\u7d44\u307f\u5408\u308f\u305b2.1 \u3059\u3079\u3066\u306e\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u5834\u54082.2 \u3069 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":3419,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3413","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/posts\/3413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/comments?post=3413"}],"version-history":[{"count":11,"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/posts\/3413\/revisions"}],"predecessor-version":[{"id":8691,"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/posts\/3413\/revisions\/8691"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/media\/3419"}],"wp:attachment":[{"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/media?parent=3413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/categories?post=3413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meister-kentei.jp\/magazine\/wp-json\/wp\/v2\/tags?post=3413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}