{"id":6574,"date":"2018-03-24T22:48:29","date_gmt":"2018-03-24T13:48:29","guid":{"rendered":"http:\/\/excelwork.info\/excel\/?p=6574"},"modified":"2018-03-25T01:00:21","modified_gmt":"2018-03-24T16:00:21","slug":"vbaregexpmethod","status":"publish","type":"post","link":"https:\/\/excelwork.info\/excel\/vbaregexpmethod\/","title":{"rendered":"VBA \u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\uff08RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30e1\u30bd\u30c3\u30c9\uff09"},"content":{"rendered":"<h2>RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30e1\u30bd\u30c3\u30c9<\/h2>\n<div class=\"m30-l\">\n<p class=\"caution4\">RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8a73\u7d30\u306b\u95a2\u3057\u3066\u306f\u3001<a href=\"https:\/\/excelwork.info\/excel\/vbaregexp\/\">VBA \u3067\u6b63\u898f\u8868\u73fe\u3092\u4f7f\u3046\uff08RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09<\/a>\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u8a73\u7d30\u306b\u95a2\u3057\u3066\u306f\u3001<a href=\"https:\/\/excelwork.info\/excel\/vbaregexpproperty\/\">RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3<\/a> \u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<br \/>\n<h3>Test \u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>\u6307\u5b9a\u3055\u308c\u305f\u6587\u5b57\u5217\u3092\u6b63\u898f\u8868\u73fe\u3067\u691c\u7d22\u3057\u305f\u7d50\u679c\u3001\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u6587\u5b57\u5217\u304c\u691c\u7d22\u3055\u308c\u305f\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Test<\/strong> ( <em>string<\/em> ) <\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>string&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u6b63\u898f\u8868\u73fe\u306b\u3088\u308b\u691c\u7d22\u306e\u5bfe\u8c61\u3068\u306a\u308b\u30c6\u30ad\u30b9\u30c8\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>\u623b\u308a\u5024&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30d6\u30fc\u30eb\u578b\uff08Boolean\uff09\u3002\u30d1\u30bf\u30fc\u30f3\u306b\u4e00\u81f4\u3059\u308b\u6587\u5b57\u5217\u304c\u898b\u3064\u304b\u308b\u3068 <strong>True<\/strong>\u3001\u898b\u3064\u304b\u3089\u306a\u3044\u3068 <strong>False<\/strong> \u3092\u8fd4\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Test \u30e1\u30bd\u30c3\u30c9\u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_RegExp_Test()\r\n\r\n' \u53c2\u7167\u8a2d\u5b9a\uff1aMicrosoft VBScript Regular Expressions 5.5\r\n    \r\n    Dim re As RegExp\r\n    Dim myStr1 As String\r\n    Dim myStr2 As String\r\n    Dim orgStr As String\r\n    \r\n    Set re = New RegExp\r\n    \r\n    orgStr = \"abc def ghi jkl abc ghi\"\r\n    \r\n    re.Pattern = \"abc\"\r\n    If re.Test(orgStr) Then\r\n        myStr1 = \"\u691c\u7d22\u6587\u5b57\u5217\u300c\" & re.Pattern & \"\u300d\u306f\u898b\u3064\u304b\u308a\u307e\u3057\u305f\u3002\"\r\n    Else\r\n        myStr1 = \"\u691c\u7d22\u6587\u5b57\u5217\u300c\" & re.Pattern & \"\u300d\u306f\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\"\r\n    End If\r\n    \r\n    re.Pattern = \"fgh\"\r\n    If re.Test(orgStr) Then\r\n        myStr2 = \"\u691c\u7d22\u6587\u5b57\u5217\u300c\" & re.Pattern & \"\u300d\u306f\u898b\u3064\u304b\u308a\u307e\u3057\u305f\u3002\"\r\n    Else\r\n        myStr2 = \"\u691c\u7d22\u6587\u5b57\u5217\u300c\" & re.Pattern & \"\u300d\u306f\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\"\r\n    End If\r\n    \r\n    MsgBox \"\u691c\u7d22\u6587\u5b57\u5217=\"\"\" & orgStr & \"\"\"\" & vbCrLf & myStr1 & vbCrLf & myStr2\r\n    \r\nEnd Sub\r\n\r\n\u3000\r\n    <\/pre>\n<br \/>\n<p><strong>\u5b9f\u884c\u7d50\u679c<\/strong><\/p>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod01.jpg?ssl=1\" rel=\"lightbox[6574]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod01.jpg?resize=256%2C178&#038;ssl=1\" alt=\"RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3000Test \u30e1\u30bd\u30c3\u30c9\" width=\"256\" height=\"178\" class=\"alignnone size-full wp-image-6576\" data-recalc-dims=\"1\" \/><\/a><\/p><\/div>\n<br \/>\n<h3>Replace \u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>\u6b63\u898f\u8868\u73fe\u3067\u691c\u7d22\u3057\u3066\u898b\u3064\u304b\u3063\u305f\u6587\u5b57\u5217\u3092\u7f6e\u63db\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Replace<\/strong> ( <em>string1<\/em>, <em>string2<\/em> ) <\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>string1&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u691c\u7d22\u304a\u3088\u3073\u7f6e\u63db\u306e\u5bfe\u8c61\u3068\u306a\u308b\u30c6\u30ad\u30b9\u30c8\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>string2&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u7f6e\u63db\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>\u623b\u308a\u5024&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u6b63\u898f\u8868\u73fe\u3067\u691c\u7d22\u3057\u3001\u30de\u30c3\u30c1\u3057\u305f\u6587\u5b57\u5217\u3092<strong>\u5f15\u6570 string2<\/strong> \u3067\u6307\u5b9a\u3057\u305f\u6587\u5b57\u5217\u306b\u7f6e\u304d\u63db\u3048\u305f\u6587\u5b57\u5217\u3092\u8fd4\u3057\u307e\u3059\u3002\u30de\u30c3\u30c1\u3059\u308b\u3082\u306e\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u3001\u5143\u306e\u6587\u5b57\u5217\uff08<strong>\u5f15\u6570 string1<\/strong> \u3067\u6307\u5b9a\u3057\u305f\u6587\u5b57\u5217\uff09\u3092\u8fd4\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Replace \u30e1\u30bd\u30c3\u30c9 \u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_RegExp_Replace()\r\n\r\n' \u53c2\u7167\u8a2d\u5b9a\uff1aMicrosoft VBScript Regular Expressions 5.5\r\n    \r\n    Dim re As RegExp\r\n    Dim myStr As String\r\n    Dim orgStr As String\r\n\r\n    Set re = New RegExp\r\n    \r\n    orgStr = \"abc def ghi jkl abc ghi\"\r\n    \r\n    re.Pattern = \"abc\"\r\n    re.Global = True\r\n    \r\n    myStr = \"\u7f6e\u63db\u524d\uff1a\" & orgStr & vbCrLf\r\n    myStr = myStr & \"\u7f6e\u63db\u5f8c\uff1a\" & re.Replace(orgStr, \"xyz\")\r\n    \r\n    MsgBox myStr\r\n        \r\nEnd Sub\r\n\u3000\r\n    <\/pre>\n<br \/>\n<p><strong>\u5b9f\u884c\u7d50\u679c<\/strong><\/p>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod02.jpg?ssl=1\" rel=\"lightbox[6574]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod02.jpg?resize=216%2C163&#038;ssl=1\" alt=\"RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8 Replace \u30e1\u30bd\u30c3\u30c9\" width=\"216\" height=\"163\" class=\"alignnone size-full wp-image-6578\" data-recalc-dims=\"1\" \/><\/a><\/p><\/div>\n<br \/>\n<h3>Execute \u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>\u6b63\u898f\u8868\u73fe\u3067\u691c\u7d22\u3057\u305f\u7d50\u679c\u3092 <a href=\"#matches\">Matches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/a>\u3068\u3057\u3066\u8fd4\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <em>object<\/em>.<strong>Execute<\/strong> ( <em>string<\/em> ) <\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>string&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u6b63\u898f\u8868\u73fe\u306b\u3088\u308b\u691c\u7d22\u306e\u5bfe\u8c61\u3068\u306a\u308b\u30c6\u30ad\u30b9\u30c8\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"Execute \u30e1\u30bd\u30c3\u30c9 \u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_RegExp_Execute1()\r\n\r\n' \u53c2\u7167\u8a2d\u5b9a\uff1aMicrosoft VBScript Regular Expressions 5.5\r\n    \r\n    Dim re As RegExp\r\n    Dim mc As MatchCollection\r\n    Dim m As Match\r\n    Dim myStr As String\r\n    Dim orgStr As String\r\n    Dim i As Long\r\n\r\n    Set re = New RegExp\r\n    \r\n    orgStr = \"aabbcc axxyyzzc ghi jkl abbaac ghi\"\r\n    \r\n    re.Pattern = \"a.+?c\"    '\u300ca\u300d\u3067\u59cb\u307e\u308a\u300cc\u300d\u3067\u7d42\u308f\u308b\u6587\u5b57\u5217\uff08\u6700\u77ed\uff09\u306b\u4e00\u81f4\r\n    re.Global = True\r\n    \r\n    Set mc = re.Execute(orgStr)\r\n    For i = 0 To mc.Count - 1\r\n        Set m = mc.Item(i)\r\n        myStr = myStr & m.FirstIndex & \"\uff1a\" & _\r\n                vbTab & m.Value & \"\uff08\" & _\r\n                m.Length & \"\uff09\" & vbCrLf\r\n    Next i\r\n    \r\n    MsgBox \"\u4f4d\u7f6e\uff1a\" & vbTab & \"\u5024\uff08\u9577\u3055\uff09\" & vbCrLf & myStr\r\n        \r\nEnd Sub\r\n\u3000\r\n    <\/pre>\n<br \/>\n<p><strong>\u5b9f\u884c\u7d50\u679c<\/strong><\/p>\n<p><a href=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod03.jpg?ssl=1\" rel=\"lightbox[6574]\"><img loading=\"lazy\" src=\"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod03.jpg?resize=184%2C193&#038;ssl=1\" alt=\"RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8 Execute \u30e1\u30bd\u30c3\u30c9\" width=\"184\" height=\"193\" class=\"alignnone size-full wp-image-6588\" data-recalc-dims=\"1\" \/><\/a><\/p><\/div>\n<\/div>\n<br \/><br \/>\n<h2 id=\"matches\">Matches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/h2>\n<div class=\"m30-l\">\n<br \/>\n<h3>Count \u30d7\u30ed\u30d1\u30c6\u30a3<\/h3>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53d6\u5f97\uff1e<\/strong><\/span><br \/>\n    <em>object<\/em>.<strong>Matches<\/strong>.<strong>Count<\/strong><\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>\u623b\u308a\u5024&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>Execute \u30e1\u30bd\u30c3\u30c9<\/strong>\u306b\u3088\u308a\u53d6\u5f97\u3057\u305f <strong>Matche \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong>\u306e\u6570\u3002<\/li>\n<\/ul>\n<br \/><\/div>\n<br \/>\n<h3>Item \u30d7\u30ed\u30d1\u30c6\u30a3<\/h3>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53d6\u5f97\uff1e<\/strong><\/span><br \/>\n    <em>object<\/em>.<strong>Matches<\/strong> [.<strong>Item<\/strong>] (<em>number<\/em>)<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>number&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u5024\uff08<b>0<\/b> \u304b\u3089 <b>Matches.Count &#8211; 1<\/b> \u307e\u3067\u306e\u6570\u5024\uff09\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>\u623b\u308a\u5024&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<strong>Execute \u30e1\u30bd\u30c3\u30c9<\/strong>\u306b\u3088\u308a\u53d6\u5f97\u3057\u305f <strong>Matche \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong>\u3002<\/li>\n<\/ul>\n<br \/><\/div>\n<\/div>\n<br \/><br \/>\n<h2 id=\"matche\">Matche \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u7b49<\/h2>\n<div class=\"m30-l\">\n<br \/>\n<h3>FirstIndex \u30d7\u30ed\u30d1\u30c6\u30a3<\/h3>\n<p>\u30de\u30c3\u30c1\u3057\u305f\u90e8\u5206\u306e\u4f4d\u7f6e\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53d6\u5f97\uff1e<\/strong><\/span><br \/>\n    <em>object<\/em>.<strong>FirstIndex<\/strong><\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>Matche \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>\u623b\u308a\u5024&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u691c\u7d22\u6587\u5b57\u5217\u306e\u6700\u521d\u306e\u4f4d\u7f6e\u30920\u3068\u3059\u308b\u30aa\u30d5\u30bb\u30c3\u30c8\u5024\u3002<\/li>\n<\/ul>\n<br \/><\/div>\n<br \/>\n<h3>Length \u30d7\u30ed\u30d1\u30c6\u30a3<\/h3>\n<p>\u30de\u30c3\u30c1\u3057\u305f\u6587\u5b57\u5217\u306e\u9577\u3055\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53d6\u5f97\uff1e<\/strong><\/span><br \/>\n    <em>object<\/em>.<strong>Length<\/strong>\n  <\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>Matche \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/><\/div>\n<br \/>\n<h3>Value \u30d7\u30ed\u30d1\u30c6\u30a3<\/h3>\n<p>\u30de\u30c3\u30c1\u3057\u305f\u6587\u5b57\u5217\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53d6\u5f97\uff1e<\/strong><\/span><br \/>\n    <em>object<\/em>.<strong>Value<\/strong><\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>Matche \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<br \/><\/div>\n<br \/>\n<h3>SubMatches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/h3>\n<p>\u6b63\u898f\u8868\u73fe\u3067\u691c\u7d22\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u30b5\u30d6\u6761\u4ef6\u304c\u53d6\u5f97\u3092\u793a\u3059 () \uff08\u30ab\u30c3\u30b3\uff09\u3067\u56f2\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u306b\u30b5\u30d6\u30de\u30c3\u30c1\u6587\u5b57\u5217\u304c 0 \u500b\u4ee5\u4e0a\u4f5c\u6210\u3055\u308c\u307e\u3059\uff08SubMatches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\uff09\u3002SubMatches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u5404\u9805\u76ee\u3078\u306f\u3001<strong>SubMatches(number)<\/strong> \u306e\u5f62\u3067\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<br \/>\n<div class=\"kkbox\"><strong>\u3010\u66f8\u5f0f\u3011<\/strong><\/p>\n<p>    <span class=\"red\"><strong>\uff1c\u53d6\u5f97\uff1e<\/strong><\/span><br \/>\n    <em>object<\/em>.<strong>SubMatches<\/strong>( <em>number<\/em> )<\/p><\/div>\n<br \/>\n<h4>\u5f15\u6570\u30fb\u623b\u308a\u5024<\/h4>\n<div class=\"m30-l\">\n<ul style=\"margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;\">\n<li>object&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;\u5bfe\u8c61\u3068\u306a\u308b <span class=\"red\"><strong>Matche \u30aa\u30d6\u30b8\u30a7\u30af\u30c8<\/strong><\/span>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>number&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;<b>0<\/b> \u4ee5\u4e0a <b>SubMatches.Count -1<\/b> \u307e\u3067\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u5024\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li>\u623b\u308a\u5024&nbsp;&nbsp;\u30fb\u30fb\u30fb&nbsp;&nbsp;SubMatches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3002SubMatches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u5404\u9805\u76ee\u306f\u3001\u6b63\u898f\u8868\u73fe\u306b\u3088\u3063\u3066\u691c\u7d22\u304a\u3088\u3073\u53d6\u5f97\u3055\u308c\u308b\u6587\u5b57\u5217\u3067\u3059\u3002<\/li>\n<\/ul>\n<br \/>\n<pre class=\"lang:vb mark:0 decode:true \" title=\"SubMatches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3 \u4f7f\u7528\u4f8b\" data-url=\"http:\/\/example.co.jp\" >\r\n\u3000\r\nSub Sample_RegExp_Execute2()\r\n\r\n' \u53c2\u7167\u8a2d\u5b9a\uff1aMicrosoft VBScript Regular Expressions 5.5\r\n    \r\n    Dim re As RegExp\r\n    Dim mc As MatchCollection\r\n    Dim m As Match\r\n    Dim myStr As String\r\n    Dim tmpStr As String\r\n    Dim orgStr As String\r\n    Dim i As Long\r\n    \r\n    Set re = New RegExp\r\n    \r\n    orgStr = \"AAAAA BB001 AA202 jk345 abcde i030k X12345\"\r\n    \r\n    '\u300c\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u5927\u6587\u5b57\u306e\u30b0\u30eb\u30fc\u30d7\u300d\u300c\u6570\u5024\u306e\u30b0\u30eb\u30fc\u30d7\u300d\u306b\u4e00\u81f4\r\n    re.Pattern = \"([A-Z]+)([0-9]+)\"\r\n    re.Global = True\r\n    \r\n    Set mc = re.Execute(orgStr)\r\n    \r\n    For Each m In mc\r\n    \r\n        myStr = myStr & m.FirstIndex & \":\" & vbTab\r\n        tmpStr = \"\"\r\n        For i = 0 To m.SubMatches.Count - 1\r\n            If tmpStr <> \"\" Then\r\n                tmpStr = tmpStr & \" - \" & m.SubMatches(i)\r\n            Else\r\n                tmpStr = tmpStr & m.SubMatches(i)\r\n            End If\r\n        Next i\r\n        myStr = myStr & tmpStr & vbCrLf\r\n    \r\n    Next m\r\n    \r\n    MsgBox myStr\r\n        \r\nEnd Sub\r\n\u3000\r\n    <\/pre>\n<br \/>\n<p><strong>\u5b9f\u884c\u7d50\u679c<\/strong><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod04.jpg?ssl=1\" rel=\"lightbox[6574]\"><img loading=\"lazy\" src=\"https:\/\/i0.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod04.jpg?resize=156%2C178&#038;ssl=1\" alt=\"RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8 Matches \u30b3\u30ec\u30af\u30b7\u30e7\u30f3\" width=\"156\" height=\"178\" class=\"alignnone size-full wp-image-6589\" data-recalc-dims=\"1\" \/><\/a><\/p><\/div>\n<\/div>\n<br \/><br \/>\n<h2>\u6b63\u898f\u8868\u73fe\u306e\u30d1\u30bf\u30fc\u30f3\u4f8b<\/h2>\n<br \/>\n<div class=\"m30-l\">\n<table>\n<tr>\n<td align = \"center\" width=\"200\" bgcolor=\"#fffccc\"><strong>\u691c\u7d22\u5185\u5bb9<\/strong><\/td>\n<td align = \"center\" width=\"450\" bgcolor=\"#fffccc\"><strong>\u6b63\u898f\u8868\u73fe\u306e\u30d1\u30bf\u30fc\u30f3\u4f8b<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9<\/td>\n<td width=\"450\">^([\\w]+)([\\w\\.-]+)@([\\w_\\-]+)\\.([\\w_\\.\\-]*)[a-z][a-z]$<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">HTML\u306e\u30bf\u30b0<\/td>\n<td width=\"450\"><(.*)>.*<\\\/\\1><\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u3072\u3089\u304c\u306a\uff085\u6587\u5b57\uff09<\/td>\n<td width=\"450\">[\u3042-\u3093]{5}<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u30ab\u30bf\u30ab\u30ca\uff083\u6587\u5b57\u4ee5\u4e0a\uff09<\/td>\n<td width=\"450\">[\u30a2-\u30f3]{3,}<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u534a\u89d2\u30ab\u30bf\u30ab\u30ca\uff085\u6587\u5b57\u4ee5\u4e0b\uff09<\/td>\n<td width=\"450\">[\uff66-\uff9f]{1,5}<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u534a\u89d2\u82f1\u6570\uff085\u6587\u5b57\u4ee5\u4e0a10\u6587\u5b57\u4ee5\u4e0b\uff09<\/td>\n<td width=\"450\">[a-zA-Z0-9]{5,10}<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u90f5\u4fbf\u756a\u53f7<\/td>\n<td width=\"450\">^(\\d{3})-(\\d{4})$<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u96fb\u8a71\u756a\u53f7\uff08\u5e02\u5916\u5c40\u756a\u542b\u3080\uff09<\/td>\n<td width=\"450\">^0(\\d{1}-\\d{4}|\\d{2}-\\d{3}|\\d{3}-\\d{2}|\\d{4}-\\d{1})-\\d{4}$<\/td>\n<\/tr>\n<tr>\n<td width=\"200\">\u96fb\u8a71\u756a\u53f7\uff08\u643a\u5e2f\uff09<\/td>\n<td width=\"450\">^0[7|8|9|]0-\\d{4}-\\d{4}$<\/td>\n<\/tr>\n<\/table>\n<p>\n<\/div>\n<br \/>\n","protected":false},"excerpt":{"rendered":"<p>RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30e1\u30bd\u30c3\u30c9 RegExp \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u8a73\u7d30\u306b\u95a2\u3057\u3066\u306f &#8230; <\/p>\n","protected":false},"author":1,"featured_media":6576,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"amp_status":"","spay_email":"","jetpack_publicize_message":""},"categories":[37],"tags":[954,996,1055,1056,1053,518,1054,63,1048,955,1047],"jetpack_featured_media_url":"https:\/\/i2.wp.com\/excelwork.info\/excel\/wp\/wp-content\/uploads\/2017\/11\/vbaregexpmethod01.jpg?fit=256%2C178&ssl=1","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4Ye9i-1I2","_links":{"self":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6574"}],"collection":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/comments?post=6574"}],"version-history":[{"count":19,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6574\/revisions"}],"predecessor-version":[{"id":6686,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/posts\/6574\/revisions\/6686"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media\/6576"}],"wp:attachment":[{"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/media?parent=6574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/categories?post=6574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelwork.info\/excel\/wp-json\/wp\/v2\/tags?post=6574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}