<?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: quotes in regexp in macros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/224439#M40335</link>
    <description>&lt;P&gt;You are working too hard to create the regex expression. Let's break it down. &amp;nbsp;To match any character that is not a double quote you need [^"]. To match that surrounded by quotes you just need to add the quotes. To have that match the full string then you need at have ^ before and $ after. &amp;nbsp;Plus you need the beginning and ending slashes. Since your single quotes are balanced and your unbalanced double quote is&amp;nbsp;inside of single quotes then no macro quoting of the regex is required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pos=%sysfunc(prxmatch(/^'[^"]'$/,%superq(a)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Sep 2015 16:26:54 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2015-09-08T16:26:54Z</dc:date>
    <item>
      <title>quotes in regexp in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/216878#M39960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;Hi all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;I am validating values, looking for quoted single characters, except quoted quotes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;'a'&amp;nbsp; yes&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;'"'&amp;nbsp; no&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;'A&amp;nbsp;&amp;nbsp; no&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;Abc&amp;nbsp; no&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;This works fine, but I had to fight the code to make it work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;Here b works, c doesn't.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; a="'";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; b=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(prxmatch(/^(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%'|%"))[^&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%"%')]\1$/,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%superq&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(a)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; c=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(prxmatch(/^(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%'|%"))[^&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%'%")]\1$/,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%superq&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(a)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;The only change is the order of the quotes in the regexp list expression. SAS wants them "closed" in the right order or gets confused.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;This order should not matter (it is just a list), and does not matter in SAS code or when &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;using prxparse:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; d=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(prxmatch(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(prxparse(/^(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%'|%"))[^&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%"%')]\1$/)),&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%superq&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(a)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt; e=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(prxmatch(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(prxparse(/^(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%'|%"))[^&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(%'%")]\1$/)),&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;%superq&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black;"&gt;(a)));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Helv',sans-serif; color: black;"&gt;I sent this to tech support, but was wondering whether anyone had encountered this / any comments / similar odd regexp cases.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Aug 2015 02:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/216878#M39960</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-08-05T02:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: quotes in regexp in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/224439#M40335</link>
      <description>&lt;P&gt;You are working too hard to create the regex expression. Let's break it down. &amp;nbsp;To match any character that is not a double quote you need [^"]. To match that surrounded by quotes you just need to add the quotes. To have that match the full string then you need at have ^ before and $ after. &amp;nbsp;Plus you need the beginning and ending slashes. Since your single quotes are balanced and your unbalanced double quote is&amp;nbsp;inside of single quotes then no macro quoting of the regex is required.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pos=%sysfunc(prxmatch(/^'[^"]'$/,%superq(a)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2015 16:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/224439#M40335</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-09-08T16:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: quotes in regexp in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/226027#M40637</link>
      <description>&lt;P&gt;Tom i think you missed the fact that the string can be singled quoted *or doubled quoted*. The double quote option was not obvious from my text though it was used in the second example.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2015 12:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/226027#M40637</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-09-17T12:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: quotes in regexp in macros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/226028#M40638</link>
      <description>Tech support as lodged a defect.</description>
      <pubDate>Thu, 17 Sep 2015 11:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quotes-in-regexp-in-macros/m-p/226028#M40638</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-09-17T11:52:26Z</dc:date>
    </item>
  </channel>
</rss>

