{"id":62,"date":"2004-12-10T00:47:52","date_gmt":"2004-12-10T00:47:52","guid":{"rendered":"http:\/\/gaisan.com\/wordp\/?p=62"},"modified":"2004-12-10T00:47:52","modified_gmt":"2004-12-10T00:47:52","slug":"the-gaisan-regular-expression-toolkit","status":"publish","type":"post","link":"http:\/\/gaisan.com\/blogs\/?p=62","title":{"rendered":"The Gaisan regular expression toolkit"},"content":{"rendered":"<p>If you want to match URL&#8217;s reliably without creating a regexp monster so big that you need to connect up the digital projector just so you can work on it then this is something tasty I&#8217;ve come up with. Demonstrated in java, my language of choice<br \/>\n<code><br \/>\nPattern urlPattern = Pattern.compile(\"(((URL:|url:|http:|htt:)\\\\\/\\\\\/)|www\\\\.)(((([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]\"+<br \/>\n\"|[A-Za-z0-9])\\\\.)*([a-zA-Z][A-Za-z0-9-]*[A-Za-z0-9]|[a-zA-Z]))|([0-9]+\\\\.[0-9]+\\\\.[0-9]+\\\\.[0-9]+))\"+<br \/>\n\"(:[0-9]+)?(\\\\\/([a-zA-Z0-9$_.+!*'(,);:@&=\\\\~\\\\#-]|%[0-9A-Fa-f][0-9A-Fa-f])*(\\\\\/([a-zA-Z0-9$_.+!*'(,)\"+<br \/>\n\";:@&=\\\\~\\\\#-]|%[0-9A-Fa-f][0-9A-Fa-f])*)*(\\\\?([a-zA-Z0-9$_.+!*'(,);:@&=\\\\~\\\\#-]|%[0-9A-Fa-f][0-9A-Fa-f])*)?)?)\";<br \/>\nMatcher urlMatcher = urlPattern.matcher(\"http:\/\/streamserver.gaisan.com\/ourapplication?sd=234324&cam=1\");<br \/>\nboolean matches2 = m2.matches();<br \/>\nSystem.out.println(\"Match should be true:\\t\" + urlMatcher.matches());<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to match URL&#8217;s reliably without creating a regexp monster so big that you need to connect up the digital projector just so you can work on it then this is something tasty I&#8217;ve come up with. Demonstrated in java, my language of choice Pattern urlPattern = Pattern.compile(&#8220;(((URL:|url:|http:|htt:)\\\\\/\\\\\/)|www\\\\.)(((([A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]&#8221;+ &#8220;|[A-Za-z0-9])\\\\.)*([a-zA-Z][A-Za-z0-9-]*[A-Za-z0-9]|[a-zA-Z]))|([0-9]+\\\\.[0-9]+\\\\.[0-9]+\\\\.[0-9]+))&#8221;+ &#8220;(:[0-9]+)?(\\\\\/([a-zA-Z0-9$_.+!*'(,);:@&#038;=\\\\~\\\\#-]|%[0-9A-Fa-f][0-9A-Fa-f])*(\\\\\/([a-zA-Z0-9$_.+!*'(,)&#8221;+ &#8220;;:@&#038;=\\\\~\\\\#-]|%[0-9A-Fa-f][0-9A-Fa-f])*)*(\\\\?([a-zA-Z0-9$_.+!*'(,);:@&#038;=\\\\~\\\\#-]|%[0-9A-Fa-f][0-9A-Fa-f])*)?)?)&#8221;; Matcher urlMatcher [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/62"}],"collection":[{"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":0,"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/62\/revisions"}],"wp:attachment":[{"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}