<?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: Prxmatch to match a pattern of words in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685308#M207831</link>
    <description>Thanks a lot Andreas for an easy solution.</description>
    <pubDate>Mon, 21 Sep 2020 06:03:03 GMT</pubDate>
    <dc:creator>SK_11</dc:creator>
    <dc:date>2020-09-21T06:03:03Z</dc:date>
    <item>
      <title>Prxmatch to match a pattern of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685301#M207827</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to find a pattern from a sentence e.g I am trying find " I am" and "live" and "with my parents" from "I am 20 years old and I live happily with my parents".&lt;/P&gt;&lt;P&gt;The code I tried is ;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;sentence='I am 20 years old and I live happily with my parents';&lt;BR /&gt;pattern=prxparse('/(I am)\w*(live)\w*(with my parents)/i');&lt;BR /&gt;b=prxmatch(pattern,sentence);&lt;/P&gt;&lt;P&gt;run:&lt;/P&gt;&lt;P&gt;I am getting 0 value for b&lt;/P&gt;&lt;P&gt;Any help in this regards will be very much appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 03:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685301#M207827</guid>
      <dc:creator>SK_11</dc:creator>
      <dc:date>2020-09-21T03:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch to match a pattern of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685306#M207829</link>
      <description>&lt;P&gt;Your aren't incorporating the blanks between the words you want to find and all other chars in the text. The following regex seems to solve the issue:&lt;/P&gt;
&lt;PRE&gt;(I am)(\w*\W)*(live)(\w*\W)*(with my parents)&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Sep 2020 05:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685306#M207829</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-21T05:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch to match a pattern of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685307#M207830</link>
      <description>&lt;P&gt;It seems that the string&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;(\w*\W)*&lt;/STRONG&gt; is used to skip any number of words.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Getting result b=1 means that the sentence contains all required substrings&lt;/P&gt;
&lt;P&gt;in the defined order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next code is searching each sub string, if it exists in the sentence:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  sentence='I am 20 years old and I live happily with my parents';
  prxid = prxparse('/(I am)|(live)|(my parents)/');

  length unit $20;
  start=1;
  stop=length(sentence);

  do while (1);
     call prxnext(prxid,start,stop,sentence,pos,len);
     if pos=0 then leave;
    unit = compress(substr(sentence,pos,len));
    put unit=;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 05:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685307#M207830</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-09-21T05:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Prxmatch to match a pattern of words</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685308#M207831</link>
      <description>Thanks a lot Andreas for an easy solution.</description>
      <pubDate>Mon, 21 Sep 2020 06:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Prxmatch-to-match-a-pattern-of-words/m-p/685308#M207831</guid>
      <dc:creator>SK_11</dc:creator>
      <dc:date>2020-09-21T06:03:03Z</dc:date>
    </item>
  </channel>
</rss>

