<?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: empty string between look-behind and look-ahead in regular expression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609357#M177410</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how about that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  txt = "Name: Alfred"||'0D'x||"Age: 34"||'0D'x||"Height: 69"; output;
  txt = "Name: Anna"||'0D'x||"Age:  "||'0D'x||"Height: 69"; output;
run;


data a;
  set have;

  pat = prxparse("/(\bAge: ).*(\r)/");
  call prxsubstr(pat, txt, beg, len);
  if beg then age = scan(substr(txt, beg, len),2,":");
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Wed, 04 Dec 2019 12:55:42 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2019-12-04T12:55:42Z</dc:date>
    <item>
      <title>empty string between look-behind and look-ahead in regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609344#M177405</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  txt = "Name: Alfred"||'0D'x||"Age: "||'0D'x||"Height: 69";

  pat = prxparse("/(?&amp;lt;=Age: ).*(?=\r)/"); /* this does not work */
  call prxsubstr(pat, txt, beg, len);
  if beg then age = substr(txt, beg, len);
  output;

  pat = prxparse("/(?&amp;lt;=Age: )[^\r]*(?=\r)/"); /* this neither */
  call prxsubstr(pat, txt, beg, len);
  if beg then age = substr(txt, beg, len);
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;instead of the age, the text until the next carriage return is selected. how can i assign the empty string without changing the look expressions?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 12:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609344#M177405</guid>
      <dc:creator>Quodly</dc:creator>
      <dc:date>2019-12-04T12:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: empty string between look-behind and look-ahead in regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609357#M177410</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how about that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  txt = "Name: Alfred"||'0D'x||"Age: 34"||'0D'x||"Height: 69"; output;
  txt = "Name: Anna"||'0D'x||"Age:  "||'0D'x||"Height: 69"; output;
run;


data a;
  set have;

  pat = prxparse("/(\bAge: ).*(\r)/");
  call prxsubstr(pat, txt, beg, len);
  if beg then age = scan(substr(txt, beg, len),2,":");
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 12:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609357#M177410</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-12-04T12:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: empty string between look-behind and look-ahead in regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609361#M177412</link>
      <description>&lt;P&gt;Alternatively could try the prxchange&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  txt = "Name: Alfred"||'0D'x||"Age: 34"||'0D'x||"Height: 69"; output;
  txt = "Name: Anna"||'0D'x||"Age:  "||'0D'x||"Height: 69"; output;
run;


data a;
  set have;
age=prxchange('s/(.*age:)(.*)(\sheight.*)/$2/oi',-1,txt);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 13:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609361#M177412</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-12-04T13:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: empty string between look-behind and look-ahead in regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609364#M177413</link>
      <description>&lt;P&gt;With your example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  txt = "Name: Alfred"||'0D'x||"Age: "||'0D'x||"Height: 69";

age=prxchange('s/(.*age:)(.*)(\sheight.*)/$2/oi',-1,txt);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 13:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609364#M177413</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-12-04T13:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: empty string between look-behind and look-ahead in regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609386#M177417</link>
      <description>&lt;P&gt;The problem is not with PRX, it is with using a length of zero in a call to the SUBSTR function - the LEN variable is zero, but the SUBSTR function does not accept that - you get a note about "Invalid third argument to function SUBSTR" in both your calls.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the SUBSTRN function instead, that will correctly return an empty string.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 13:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609386#M177417</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-12-04T13:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: empty string between look-behind and look-ahead in regular expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609390#M177420</link>
      <description>great, thanks! with that i can still use those look expressions.</description>
      <pubDate>Wed, 04 Dec 2019 14:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/empty-string-between-look-behind-and-look-ahead-in-regular/m-p/609390#M177420</guid>
      <dc:creator>Quodly</dc:creator>
      <dc:date>2019-12-04T14:21:39Z</dc:date>
    </item>
  </channel>
</rss>

