<?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: Perl regular expression to get number between PT and either M or H in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789970#M252882</link>
    <description>&lt;P&gt;Amazing! Thanks both!&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jan 2022 12:36:15 GMT</pubDate>
    <dc:creator>tarheel13</dc:creator>
    <dc:date>2022-01-13T12:36:15Z</dc:date>
    <item>
      <title>Perl regular expression to get number between PT and either M or H</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789962#M252876</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lrackley_0-1642076534939.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67371i1ED0D3F0F49D6307/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lrackley_0-1642076534939.png" alt="lrackley_0-1642076534939.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here is my desired output and sample data in datalines. Can someone help me with the Perl code to get the number that is between PT and M or PT and M? It's elapsed time since dose. I know there has to be a quicker way than using scan function.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data times;
input pceltm $;
datalines;
PT30M
PT2H
PT4H
PT6H
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 12:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789962#M252876</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-01-13T12:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Perl regular expression to get number between PT and either M or H</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789966#M252878</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data times;
input pceltm $;
datalines;
PT30M
PT2H
PT4H
PT6H
PT6C
;
run;

data want;
 set times;
 pid=prxparse('/(?&amp;lt;=PT)\d+(?=M|H)/');
 call prxsubstr(pid,pceltm,p,l);
 if p then want=substr(pceltm,p,l);
 drop p l pid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 12:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789966#M252878</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-13T12:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Perl regular expression to get number between PT and either M or H</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789968#M252880</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data times;
input pceltm $;
datalines;
PT30M
PT2H
PT4H
PT6H
;
run;

data want;
   retain r;
   if _N_ = 1 then r = prxparse('/PT(\d+)[HM]/');
   set times;
   if prxmatch(r, pceltm) then time = prxposn(r, 1, pceltm);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 12:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789968#M252880</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-01-13T12:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Perl regular expression to get number between PT and either M or H</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789969#M252881</link>
      <description>&lt;P&gt;It works but I only know prxmatch and prxchange. Can you explain what p and l do? I got that pid is the pattern id.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 12:34:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789969#M252881</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-01-13T12:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Perl regular expression to get number between PT and either M or H</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789970#M252882</link>
      <description>&lt;P&gt;Amazing! Thanks both!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 12:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789970#M252882</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-01-13T12:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Perl regular expression to get number between PT and either M or H</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789972#M252884</link>
      <description>p is position and l is length  .&lt;BR /&gt;which could be used in SUBSTR() .</description>
      <pubDate>Thu, 13 Jan 2022 12:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789972#M252884</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-13T12:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Perl regular expression to get number between PT and either M or H</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789998#M252893</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data times;
input pceltm $;
datalines;
PT30M
PT2H
PT4H
PT6H
;
run;


data want;
set times;
time=prxchange('s/(PT)(\d+)((M|H))/$2/',-1,pceltm);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 14:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Perl-regular-expression-to-get-number-between-PT-and-either-M-or/m-p/789998#M252893</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2022-01-13T14:52:31Z</dc:date>
    </item>
  </channel>
</rss>

