{"id":77622,"date":"2024-09-05T11:30:22","date_gmt":"2024-09-05T10:30:22","guid":{"rendered":"https:\/\/arquiconsult.com\/?p=77622"},"modified":"2024-10-23T11:33:32","modified_gmt":"2024-10-23T10:33:32","slug":"bc-regular-expressions","status":"publish","type":"post","link":"https:\/\/arquiconsult.com\/en\/bc-regular-expressions\/","title":{"rendered":"#056 BC REGULAR EXPRESSIONS"},"content":{"rendered":"<div class=\"services_vertical horizontal_services row\" style=\"background-color: #f7f7f7; padding: 25px; border-radius: 5px; text-align: justify;\">\n<p>To meet SaaS environments and Universal Code initiative requirements, it is not possible to directly use .NET libraries. Therefore, to replace the RegEx libraries, the <strong>RegEx Codeunit<\/strong> offers the possibility of <strong>pattern matching using regular expressions<\/strong>.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n<p>The following methods are available on the RegEx codeunit:<\/p>\n<ul>\n<li><strong>IsMatch(Input: Text; Pattern: Text; StartAt: Integer): Boolean<\/strong> \u2013 Indicates whether the regular expression finds a match in the input string, beginning at the specified starting position in the string.<\/li>\n<li><strong>Match(Input: Text; Pattern: Text; StartAt: Integer; var Matches: Record Matches)<\/strong> &#8211; Searches the input string for the occurrences that match a regular expression, beginning at the specified starting position in the string.<\/li>\n<li><strong>Split(Input: Text; Pattern: Text; &#8220;Count&#8221;: Integer; var &#8220;Array&#8221;: List of [Text])<\/strong> &#8211; Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression pattern.<\/li>\n<li><strong>Replace(Input: Text; Pattern: Text; Replacement: Text; &#8220;Count&#8221;: Integer): Text<\/strong> &#8211; Replaces strings that match a regular expression pattern with a specified replacement string.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Example<\/strong><\/p>\n<p><em>Scenario<\/em>: Imagine that, for a given text, we pretend to identify all references to License Plates with the format 2Letters-2Number-2Letters.<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-77626 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario-640x301.png\" alt=\"-\" width=\"640\" height=\"301\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario-640x301.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario-320x150.png 320w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario-480x226.png 480w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario.png 762w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-77629 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario1-640x99.png\" alt=\"-\" width=\"640\" height=\"99\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario1-640x99.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario1-768x119.png 768w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario1-320x50.png 320w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario1-480x74.png 480w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario1-800x124.png 800w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/Scenario1.png 1045w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<p>&nbsp;<\/p>\n<p>The action would return:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-77633\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/The-action-would-return.png\" alt=\"-\" width=\"280\" height=\"58\" title=\"-\">\u00a0 \u00a0 \u00a0 \u00a0 <img loading=\"lazy\" class=\"alignnone size-full wp-image-77636\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/The-action-would-return2.png\" alt=\"-\" width=\"269\" height=\"59\" title=\"-\"><\/p>\n<p><em>Variations<\/em>:<\/p>\n<ul>\n<li>Be case Insensitive: [A-Z,a-z]{2}\\-[0-9]{2}\\-[A-Z,a-z]{2}<\/li>\n<li>Find any License Plate: [A-Z]{2}\\-[0-9]{2}\\-[A-Z]{2}|[0-9]{2}\\-[A-Z]{2}\\-[A-Z]{2}|[A-Z]{2}\\-[A-Z]{2}\\-[0-9]{2}<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>To ease developers\u2019 life, <a href=\"https:\/\/regex101.com\/\" target=\"_blank\" rel=\"noopener\">RegEx101<\/a> is a website with a built-in manual where the regular expressions can be created and tested.<\/p>\n<p>If these expressions are frequently used, it might be a good idea to have an auxiliar table linked with pattern by the OnLookUp trigger:<\/p>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-77638 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/OnLookUp-trigger-640x290.png\" alt=\"-\" width=\"640\" height=\"290\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/OnLookUp-trigger-640x290.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/OnLookUp-trigger-320x145.png 320w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/OnLookUp-trigger-480x217.png 480w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2024\/09\/OnLookUp-trigger.png 767w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-77622\" data-postid=\"77622\" class=\"themify_builder_content themify_builder_content-77622 themify_builder tf_clear\">\n    \t<!-- module_row -->\n\t<div  data-lazy=\"1\" class=\"module_row themify_builder_row tb_nus1581 tb_first tf_clearfix\">\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_cai8581 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module text -->\n<div  class=\"module module-text tb_9tkr581 arquitps-data  \" data-lazy=\"1\">\n        <div  class=\"tb_text_wrap\">\n    <p><script>\njQuery(\".tbp_post_month:contains(Janeiro)\").html(\"January\");\n\njQuery(\".tbp_post_month:contains(Fevereiro)\").html(\"February\");\n\n\njQuery(\".tbp_post_month:contains(Mar\u00e7o)\").html(\"March\");\n\n\njQuery(\".tbp_post_month:contains(Abril)\").html(\"April\");\n\n\njQuery(\".tbp_post_month:contains(Maio)\").html(\"May\");\n\n\njQuery(\".tbp_post_month:contains(Junho)\").html(\"June\");\n\n\njQuery(\".tbp_post_month:contains(Julho)\").html(\"July\");\n\njQuery(\".tbp_post_month:contains(Agosto)\").html(\"August\");\n\njQuery(\".tbp_post_month:contains(Setembro)\").html(\"September\");\n\njQuery(\".tbp_post_month:contains(Outubro)\").html(\"October\");\n\njQuery(\".tbp_post_month:contains(Novembro)\").html(\"November\");\n\njQuery(\".tbp_post_month:contains(Dezembro)\").html(\"December\");\t\n\n\n\n<\/script><\/p>    <\/div>\n<\/div>\n<!-- \/module text -->\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t\t<!-- module_row -->\n\t<div  data-anchor=\"sucesso\" data-hide-anchor=\"1\" data-lazy=\"1\" class=\"module_row themify_builder_row sucesso repeat tb_has_section tb_section-sucesso tb_u0z5106 tf_clearfix\" >\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_0fw8107 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module buttons -->\n<div  class=\"module module-buttons tb_6id7107 buttons-horizontal transparent popmake-24705 large circle tf_textc\" data-lazy=\"1\">\n    \t<div class=\"module-buttons-item tf_inline_b\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"ui builder_button tb_default_color\" >\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"tf_inline_b tf_vmiddle\">Give as a Feedback and Suggest Questions<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t    \t<\/div>\n\t<\/div>\n<!-- \/module buttons -->\n\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t<\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>To meet SaaS environments and Universal Code initiative requirements, it is not possible to directly use .NET libraries. Therefore, to replace the RegEx libraries, the RegEx Codeunit offers the possibility of pattern matching using regular expressions. &nbsp; The following methods are available on the RegEx codeunit: IsMatch(Input: Text; Pattern: Text; StartAt: Integer): Boolean \u2013 Indicates [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":77644,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2099,2124],"tags":[2590,1339,2015,2591,2592,2589],"acf":[],"_links":{"self":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/77622"}],"collection":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/comments?post=77622"}],"version-history":[{"count":0,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/77622\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media\/77644"}],"wp:attachment":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media?parent=77622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/categories?post=77622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/tags?post=77622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}