<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I include all scenarios when writing Regular Expressions functions (prxchange) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503264#M134450</link>
    <description>&lt;P&gt;All these expressions do what you want and give the same result for your string.&lt;/P&gt;
&lt;P&gt;The difference between B and C is that B capture any &amp;lt;E tag while C also needs T= inside.&lt;/P&gt;
&lt;P&gt;D is the same as C except that C needs something before &amp;lt;E, so won't capture &amp;lt;E if it's at the start of the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;propose a better one&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is 'better"?&lt;/P&gt;
&lt;P&gt;What's wrong with these?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want restrict the capture to &lt;FONT face="courier new,courier"&gt;&amp;lt;E T="{digits"}&amp;gt;&lt;/FONT&gt; you could use this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;E=prxchange('s/(&amp;lt;E T="\d+"&amp;gt;(.+?)&amp;lt;\/E&amp;gt;)(.+?)/\2\3/',-1,A);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;[After reading&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;'s reply: he is right about replacement of course, and his expression is a bit simpler.]&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Oct 2018 22:22:51 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-10-10T22:22:51Z</dc:date>
    <item>
      <title>How do I include all scenarios when writing Regular Expressions functions (prxchange)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503230#M134428</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am really not good at using Perl&amp;nbsp;Perl's regular expressions functions in data step... Below are several different expressions I wrote for the Prxchange function, and this is for searching for patterns and remove the &amp;lt;E T="XXX"&amp;gt;&amp;lt;\E&amp;gt; tag but keep the content within this tag. I wonder what exactly is the difference between each expression and if any one can advise me on which one is the best (or even better -- propose a better one) that would be really awesome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(XXX can be any integer)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;A='&amp;lt;P&amp;gt;&amp;lt;E T="12"&amp;gt;Test &amp;lt;/E&amp;gt;(a) &amp;lt;E T="03"&amp;gt;Authority.&amp;lt;/E&amp;gt; This part is issued pursuant to 12 U.S.C. 1 &amp;lt;E T="99"&amp;gt;et seq.,&amp;lt;/E&amp;gt; 12 U.S.C. 24 (Seventh), and 12 U.S.C. 93a.&amp;lt;E T="5"&amp;gt;test&amp;lt;/E&amp;gt;&amp;lt;/P&amp;gt;';&lt;BR /&gt;B=prxchange('s/(.+?)(&amp;lt;E.*?&amp;gt;(.+?)&amp;lt;\/E&amp;gt;)(.+?)/\1\3\4/',-1,A);&lt;BR /&gt;C=prxchange('s/(.+?)(&amp;lt;E T=.*?&amp;gt;(.+?)&amp;lt;\/E&amp;gt;)(.+?)/\1\3\4/',-1,A);&lt;BR /&gt;D=prxchange('s/(&amp;lt;E T=.*?&amp;gt;(.+?)&amp;lt;\/E&amp;gt;)(.+?)/\2\3/',-1,A);&lt;BR /&gt;put A=/B=C=D=;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All of them generated desired results, but - none of them is completely satisfactory to me when I apply the function to the whole file( I have a large file to deal with, and this&amp;nbsp;&lt;SPAN&gt;&amp;lt;E T="XXX"&amp;gt;&amp;lt;\E&amp;gt; pattern can appear any where.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 20:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503230#M134428</guid>
      <dc:creator>ciphercong</dc:creator>
      <dc:date>2018-10-10T20:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I include all scenarios when writing Regular Expressions functions (prxchange)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503244#M134436</link>
      <description>&lt;P&gt;Only specify the searched and replacement parts, the rest of the string will remain untouched&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;E=prxchange('s/&amp;lt;E T="\d+"&amp;gt;(.*?)&amp;lt;\/E&amp;gt;/\1/', -1, A);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Oct 2018 21:23:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503244#M134436</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-10-10T21:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I include all scenarios when writing Regular Expressions functions (prxchange)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503264#M134450</link>
      <description>&lt;P&gt;All these expressions do what you want and give the same result for your string.&lt;/P&gt;
&lt;P&gt;The difference between B and C is that B capture any &amp;lt;E tag while C also needs T= inside.&lt;/P&gt;
&lt;P&gt;D is the same as C except that C needs something before &amp;lt;E, so won't capture &amp;lt;E if it's at the start of the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;&amp;nbsp;propose a better one&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is 'better"?&lt;/P&gt;
&lt;P&gt;What's wrong with these?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want restrict the capture to &lt;FONT face="courier new,courier"&gt;&amp;lt;E T="{digits"}&amp;gt;&lt;/FONT&gt; you could use this:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;E=prxchange('s/(&amp;lt;E T="\d+"&amp;gt;(.+?)&amp;lt;\/E&amp;gt;)(.+?)/\2\3/',-1,A);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;[After reading&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;'s reply: he is right about replacement of course, and his expression is a bit simpler.]&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 22:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503264#M134450</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-10-10T22:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I include all scenarios when writing Regular Expressions functions (prxchange)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503392#M134503</link>
      <description>&lt;P&gt;This is what you are looking for ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
A='&amp;lt;P&amp;gt;&amp;lt;E T="12"&amp;gt;Test &amp;lt;/E&amp;gt;(a) &amp;lt;E T="03"&amp;gt;Authority.&amp;lt;/E&amp;gt; This part is issued pursuant to 12 U.S.C. 1 &amp;lt;E T="99"&amp;gt;et seq.,&amp;lt;/E&amp;gt; 12 U.S.C. 24 (Seventh), and 12 U.S.C. 93a.&amp;lt;E T="5"&amp;gt;test&amp;lt;/E&amp;gt;&amp;lt;/P&amp;gt;';
B=prxchange('s/&amp;lt;[^&amp;lt;&amp;gt;]+&amp;gt;/ /',-1,A);
put A=/B=;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Oct 2018 13:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-include-all-scenarios-when-writing-Regular-Expressions/m-p/503392#M134503</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-10-11T13:03:47Z</dc:date>
    </item>
  </channel>
</rss>

