{"id":275,"date":"2016-11-06T21:43:08","date_gmt":"2016-11-06T14:43:08","guid":{"rendered":"http:\/\/www.oopsbox.com\/?p=275"},"modified":"2016-11-06T21:51:31","modified_gmt":"2016-11-06T14:51:31","slug":"mysql-simplemask-function","status":"publish","type":"post","link":"https:\/\/www.oopsbox.com\/?p=275","title":{"rendered":"MySQL (Simple)Mask Function"},"content":{"rendered":"<p>\u0e16\u0e49\u0e32\u0e27\u0e31\u0e19\u0e19\u0e36\u0e07\u0e40\u0e01\u0e34\u0e14\u0e08\u0e33\u0e40\u0e1b\u0e47\u0e19\u0e08\u0e23\u0e34\u0e07 \u0e46 \u0e15\u0e49\u0e2d\u0e07\u0e08\u0e31\u0e14\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e43\u0e19\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e40\u0e0a\u0e48\u0e19 \u0e2b\u0e21\u0e32\u0e22\u0e40\u0e25\u0e02\u0e42\u0e17\u0e23\u0e28\u0e31\u0e1e\u0e17\u0e4c \u0e40\u0e25\u0e02\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e15\u0e31\u0e27\u0e1b\u0e23\u0e30\u0e0a\u0e32\u0e0a\u0e19 \u0e2b\u0e23\u0e37\u0e2d\u0e08\u0e31\u0e14\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02\u0e43\u0e19\u0e41\u0e1a\u0e1a\u0e2d\u0e37\u0e48\u0e19 \u0e46 \u0e42\u0e14\u0e22\u0e1b\u0e01\u0e15\u0e34\u0e41\u0e25\u0e49\u0e27 MySQL \u0e21\u0e35\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19\u0e17\u0e35\u0e48\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e02\u0e49\u0e2d\u0e07\u0e01\u0e31\u0e1a\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25\u0e2d\u0e22\u0e39\u0e48\u0e44\u0e21\u0e48\u0e01\u0e35\u0e48\u0e15\u0e31\u0e27 \u0e40\u0e0a\u0e48\u0e19\u0e1e\u0e27\u0e01\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02(\u0e40\u0e07\u0e34\u0e19) \u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 \u0e0b\u0e36\u0e48\u0e07\u0e01\u0e47\u0e21\u0e35\u0e41\u0e04\u0e48\u0e19\u0e31\u0e49\u0e19\u0e41\u0e2b\u0e25\u0e48\u0e30 ^_^<\/p>\n<div class=\"su-note\"  style=\"border-color:#e5e54c;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFFF66;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">** \u0e2a\u0e48\u0e27\u0e19\u0e15\u0e31\u0e27\u0e41\u0e25\u0e49\u0e27\u0e44\u0e21\u0e48\u0e41\u0e19\u0e30\u0e19\u0e33\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49 (\u0e41\u0e25\u0e49\u0e27\u0e40\u0e02\u0e35\u0e22\u0e19\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e17\u0e33\u0e44\u0e21\u0e1f\u0e23\u0e30 5555) \u0e04\u0e37\u0e2d\u0e16\u0e49\u0e32\u0e08\u0e30\u0e43\u0e0a\u0e49\u0e01\u0e47\u0e21\u0e35\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e44\u0e14\u0e49\u0e41\u0e15\u0e48\u0e44\u0e21\u0e48\u0e41\u0e19\u0e30\u0e19\u0e33\u0e44\u0e07 \u0e40\u0e1b\u0e47\u0e19\u0e20\u0e32\u0e23\u0e30\u0e01\u0e32\u0e23\u0e1b\u0e23\u0e30\u0e21\u0e27\u0e25\u0e1c\u0e25\u0e42\u0e14\u0e22\u0e43\u0e0a\u0e48\u0e40\u0e2b\u0e15\u0e38 \u0e1b\u0e25\u0e48\u0e2d\u0e22\u0e43\u0e2b\u0e49\u0e40\u0e1b\u0e47\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e17\u0e35\u0e48\u0e02\u0e2d\u0e07\u0e1f\u0e23\u0e2d\u0e19\u0e17\u0e4c\u0e44\u0e1b\u0e2b\u0e25\u0e48\u0e30\u0e01\u0e31\u0e19<\/div><\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"SQL\">DELIMITER $$\r\nDROP FUNCTION IF EXISTS SIMPLEMASK$$\r\n\r\nCREATE FUNCTION SIMPLEMASK (\r\n    xvalue VARCHAR(32), \r\n    xformat VARCHAR(32)\r\n)\r\nRETURNS CHAR(32) \r\nDETERMINISTIC\r\nBEGIN\r\n\r\n    DECLARE input_len TINYINT;\r\n    DECLARE tc CHAR;\r\n    DECLARE idx TINYINT;\r\n    DECLARE yformat VARCHAR(32);\r\n    DECLARE posinsert TINYINT;\r\n    DECLARE newstring VARCHAR(32);\r\n    \r\n    # Initialize variables\r\n    SET yformat = REPLACE(xformat, '#', '');\r\n    SET input_len = LENGTH(yformat);\r\n    SET idx = 1;\r\n    SET posinsert = 0;\r\n    \r\n    # Construct formated string\r\n    WHILE ( idx &lt;= input_len ) DO\r\n        SET tc = SUBSTR(yformat, idx, 1);\r\n        SET posinsert = LOCATE(tc, xformat, (idx + posinsert));\r\n        SET newstring = CONCAT(tc, SUBSTR(xvalue, posinsert, 1));\r\n        SET xvalue = INSERT(xvalue, posinsert, 1, newstring);\r\n        SET idx = idx + 1;\r\n    END WHILE;\r\n    \r\n    RETURN xvalue;\r\n    \r\nEND $$\r\n\r\nDELIMITER ;\r\n\r\n-- Test\r\nSELECT SIMPLEMASK(1234567890123,'#-####-#####-##-#');\u00a0--\u00a0CID\/1-2345-67890-12-3<\/pre>\n<p>\u0e1b.\u0e25.<\/p>\n<ul>\n<li><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/system.windows.forms.maskedtextbox.mask(v=vs.110).aspx\">\u0e14\u0e39\u0e40\u0e23\u0e37\u0e48\u0e2d\u0e07 MaskTextBox \u0e15\u0e48\u0e2d<\/a><\/li>\n<li>\u0e40\u0e23\u0e32\u0e2d\u0e2d\u0e1b\u0e15\u0e34\u0e44\u0e21\u0e0b\u0e4c\u0e08\u0e32\u0e01\u0e40\u0e27\u0e2d\u0e23\u0e4c\u0e0a\u0e31\u0e48\u0e19\u0e43\u0e19 <a href=\"http:\/\/stackoverflow.com\/questions\/10112718\/mysql-output-masking-i-e-phone-number-ssn-etc-display-formatting\">Stackoverflow<\/a><\/li>\n<\/ul>\n<div id=\"s-share-buttons\" class=\"\"><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"fb-share-button\" data-href=\"https:\/\/www.oopsbox.com\/?p=275\" data-type=\"button_count\"><\/div><\/div><div class=\"s-single-share\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\"><\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"g-plusone\" data-size=\"medium\"><\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"\/\/www.pinterest.com\/pin\/create\/button\/\" data-pin-do=\"buttonBookmark\"  data-pin-color=\"red\"><img decoding=\"async\" src=\"\/\/assets.pinterest.com\/images\/pidgets\/pinit_fg_en_rect_red_20.png\" \/><\/a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<script type=\"text\/javascript\" async defer src=\"\/\/assets.pinterest.com\/js\/pinit.js\"><\/script>\n\t\t\t\t\t\t\t\t\t\t\t\t<\/div><div class=\"s-single-share\">\n\t\t\t\t\t\t\t\t\t\t\t\t<a href=\"mailto:?Subject=MySQL%20(Simple)Mask%20Function&Body=Here%20is%20the%20link%20to%20the%20article:%20https:\/\/www.oopsbox.com\/?p=275\" title=\"Email\" class=\"s3-email\"><img decoding=\"async\" src=\"https:\/\/www.oopsbox.com\/wp-content\/plugins\/simple-social-share\/includes\/..\/images\/share-email.png\"><\/a>\n\t\t\t\t\t\t\t\t\t\t\t<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>\u0e16\u0e49\u0e32\u0e27\u0e31\u0e19\u0e19\u0e36\u0e07\u0e40\u0e01\u0e34\u0e14\u0e08\u0e33\u0e40\u0e1b\u0e47\u0e19\u0e08\u0e23\u0e34\u0e07 \u0e46 \u0e15\u0e49\u0e2d\u0e07\u0e08\u0e31\u0e14\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e43\u0e19\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e02\u0e36\u0e49\u0e19\u0e21\u0e32\u0e40\u0e0a\u0e48\u0e19 \u0e2b\u0e21\u0e32\u0e22\u0e40\u0e25\u0e02\u0e42\u0e17\u0e23\u0e28\u0e31\u0e1e\u0e17\u0e4c \u0e40\u0e25\u0e02\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e15\u0e31\u0e27\u0e1b\u0e23\u0e30\u0e0a\u0e32\u0e0a\u0e19 \u0e2b\u0e23\u0e37\u0e2d\u0e08\u0e31\u0e14\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02\u0e43\u0e19\u0e41\u0e1a\u0e1a\u0e2d\u0e37\u0e48\u0e19 \u0e46 \u0e42\u0e14\u0e22\u0e1b\u0e01\u0e15\u0e34\u0e41\u0e25\u0e49\u0e27 MySQL \u0e21\u0e35\u0e1f\u0e31\u0e07\u0e01\u0e4c\u0e0a\u0e31\u0e48\u0e19\u0e17\u0e35\u0e48\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e02\u0e49\u0e2d\u0e07\u0e01\u0e31\u0e1a\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a\u0e01\u0e32\u0e23\u0e41\u0e2a\u0e14\u0e07\u0e1c\u0e25\u0e2d\u0e22\u0e39\u0e48\u0e44\u0e21\u0e48\u0e01\u0e35\u0e48\u0e15\u0e31\u0e27 \u0e40\u0e0a\u0e48\u0e19\u0e1e\u0e27\u0e01\u0e15\u0e31\u0e27\u0e40\u0e25\u0e02(\u0e40\u0e07\u0e34\u0e19) \u0e27\u0e31\u0e19\u0e17\u0e35\u0e48 \u0e0b\u0e36\u0e48\u0e07\u0e01\u0e47\u0e21\u0e35\u0e41\u0e04\u0e48\u0e19\u0e31\u0e49\u0e19\u0e41\u0e2b\u0e25\u0e48\u0e30 ^_^<\/p>\n","protected":false},"author":1,"featured_media":277,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[34,12],"class_list":["post-275","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developer-note","tag-mask","tag-mysql","entry"],"views":2292,"_links":{"self":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=275"}],"version-history":[{"count":3,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/275\/revisions"}],"predecessor-version":[{"id":280,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/posts\/275\/revisions\/280"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=\/wp\/v2\/media\/277"}],"wp:attachment":[{"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oopsbox.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}