{"id":200,"date":"2015-09-28T20:05:42","date_gmt":"2015-09-29T01:05:42","guid":{"rendered":"http:\/\/www.integrityautomatedsystems.com\/blog\/?p=200"},"modified":"2023-03-31T22:35:41","modified_gmt":"2023-03-31T22:35:41","slug":"formatting-phone-numbers","status":"publish","type":"post","link":"http:\/\/integrityautomatedsystems.com\/index.php\/2015\/09\/formatting-phone-numbers\/","title":{"rendered":"Formatting Phone Numbers"},"content":{"rendered":"<p>I noticed a recent post on the <a href=\"https:\/\/groups.yahoo.com\/neo\/groups\/lansa2\/info\" target=\"_blank\" rel=\"noopener\">LANSA2 Yahoo Group<\/a> that was requesting the best method of scrubbing a user entered phone number to format it in a certain way.<\/p>\n<p>There were no LANSA centric solutions given, and some of the other solutions may have worked just fine, but as this was a LANSA forum, I thought I would throw a LANSA solution in.<\/p>\n<p>I could not find any real elegant solution in LANSA (like regex), but have created a small routine which would scan the input string remove all non-numeric characters and reformat based on a format passed in from another input string.<\/p>\n<p>Currently this only handles 10 and 14 digit phone numbers. (14 has the country code in front.  E.g. 011 for North America).  I will create a similar routine another time for credit card formatting.<\/p>\n<p>Simply put this method routine in your RDMLX code, and call  it using the following statement(s).  The method &#8220;FormatPhoneNumber&#8221; takes 2 parameters.  1) The input string to be formatted and 2) the format that will be used with an &amp;# for each part of the phone number.<\/p>\n<p><a href=\"http:\/\/www.integrityautomatedsystems.com\/blog\/wp-content\/uploads\/2015\/09\/image_2015_09_28a.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-203\" src=\"http:\/\/www.integrityautomatedsystems.com\/blog\/wp-content\/uploads\/2015\/09\/image_2015_09_28a.png\" alt=\"image_2015_09_28a\" width=\"1045\" height=\"75\" srcset=\"http:\/\/integrityautomatedsystems.com\/wp-content\/uploads\/2015\/09\/image_2015_09_28a.png 1045w, http:\/\/integrityautomatedsystems.com\/wp-content\/uploads\/2015\/09\/image_2015_09_28a-300x22.png 300w, http:\/\/integrityautomatedsystems.com\/wp-content\/uploads\/2015\/09\/image_2015_09_28a-1024x73.png 1024w\" sizes=\"auto, (max-width: 1045px) 100vw, 1045px\" \/><\/a><\/p>\n<p>The first call above handles 14 digit phone and the second handles 10 digit phone numbers.<\/p>\n<p>The code is shown below, and can be downloaded <a href=\"http:\/\/www.integrityautomatedsystems.com\/blog\/wp-content\/uploads\/2015\/09\/Formatting_Phone_Numbers.txt\">here<\/a>.<\/p>\n<p><a href=\"http:\/\/www.integrityautomatedsystems.com\/blog\/wp-content\/uploads\/2015\/09\/image_2015_09_28b.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-204\" src=\"http:\/\/www.integrityautomatedsystems.com\/blog\/wp-content\/uploads\/2015\/09\/image_2015_09_28b.png\" alt=\"image_2015_09_28b\" width=\"1174\" height=\"1128\" srcset=\"http:\/\/integrityautomatedsystems.com\/wp-content\/uploads\/2015\/09\/image_2015_09_28b.png 1174w, http:\/\/integrityautomatedsystems.com\/wp-content\/uploads\/2015\/09\/image_2015_09_28b-300x288.png 300w, http:\/\/integrityautomatedsystems.com\/wp-content\/uploads\/2015\/09\/image_2015_09_28b-1024x984.png 1024w\" sizes=\"auto, (max-width: 1174px) 100vw, 1174px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I noticed a recent post on the LANSA2 Yahoo Group that was requesting the best method of scrubbing a user entered phone number to format it in a certain way. There were no LANSA centric solutions given, and some of the other solutions may have worked just fine, but as this was a LANSA forum, &hellip; <a href=\"http:\/\/integrityautomatedsystems.com\/index.php\/2015\/09\/formatting-phone-numbers\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Formatting Phone Numbers<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-200","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/posts\/200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/comments?post=200"}],"version-history":[{"count":6,"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":227,"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/posts\/200\/revisions\/227"}],"wp:attachment":[{"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/media?parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/categories?post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/integrityautomatedsystems.com\/index.php\/wp-json\/wp\/v2\/tags?post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}