{"id":140,"date":"2011-10-12T11:11:02","date_gmt":"2011-10-12T16:11:02","guid":{"rendered":"http:\/\/thenoyes.com\/littlenoise\/?p=140"},"modified":"2011-10-12T11:11:02","modified_gmt":"2011-10-12T16:11:02","slug":"explode-string","status":"publish","type":"post","link":"https:\/\/thenoyes.com\/littlenoise\/?p=140","title":{"rendered":"explode string"},"content":{"rendered":"<p>Explode a string around a delimiter without a loop.<\/p>\n<pre>DROP PROCEDURE IF EXISTS explode;\r\n\r\nDELIMITER |\r\n\r\nCREATE PROCEDURE explode( pDelim VARCHAR(32), pStr TEXT)                                \r\nBEGIN                                \r\n   DROP TABLE IF EXISTS temp_explode;                                \r\n   CREATE TEMPORARY TABLE temp_explode (id INT AUTO_INCREMENT PRIMARY KEY NOT NULL, word VARCHAR(40));                                \r\n   SET @sql := CONCAT('INSERT INTO temp_explode (word) VALUES (', REPLACE(QUOTE(pStr), pDelim, '\\'), (\\''), ')');                                \r\n   PREPARE myStmt FROM @sql;                                \r\n   EXECUTE myStmt;                                \r\nEND |   \r\n\r\nDELIMITER ;\r\n\r\n-- example call:\r\nSET @str  = \"The quick brown fox jumped over the lazy dog\"; \r\nSET @delim = \" \"; \r\n\r\nCALL explode(@delim,@str);\r\nSELECT id,word FROM temp_explode;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Explode a string around a delimiter without a loop. DROP PROCEDURE IF EXISTS explode; DELIMITER | CREATE PROCEDURE explode( pDelim VARCHAR(32), pStr TEXT) BEGIN DROP TABLE IF EXISTS temp_explode; CREATE TEMPORARY TABLE temp_explode (id INT AUTO_INCREMENT PRIMARY KEY NOT NULL, word VARCHAR(40)); SET @sql := CONCAT(&#8216;INSERT INTO temp_explode (word) VALUES (&#8216;, REPLACE(QUOTE(pStr), pDelim, &#8216;\\&#8217;), (\\&#8221;), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[],"class_list":["post-140","post","type-post","status-publish","format-standard","hentry","category-mysql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2IBF1-2g","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=140"}],"version-history":[{"count":2,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=\/wp\/v2\/posts\/140\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thenoyes.com\/littlenoise\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}