<?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: Regular expressions: match dot and comma as characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780534#M248726</link>
    <description>&lt;P&gt;Is that last table supposed to be what you want to produce? Or is it the wrong output your current code is producing?&amp;nbsp; If the latter then please provide the desired results for your example input.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Nov 2021 19:20:35 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-11-16T19:20:35Z</dc:date>
    <item>
      <title>Regular expressions: match dot and comma as characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780503#M248709</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data test;
  input name $25.;
  cards;
x., test
.x test
test x.
;
run;

data want;
   set test;
   a=prxchange('s/\b(x\.,|x\.|\x)\b//i', -1, name);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Hello there!&lt;BR /&gt;I'm trying to extract from string literal all parts which looks like &lt;EM&gt;x&lt;/EM&gt; or &lt;EM&gt;x.&lt;/EM&gt; or &lt;EM&gt;x.,&lt;/EM&gt;&lt;BR /&gt;So I've wrtitten the code above&lt;BR /&gt;A result dataset you can see in the table below&lt;BR /&gt;It seems that SAS had deleted only &lt;EM&gt;x&amp;nbsp;&lt;/EM&gt;character, not &lt;EM&gt;x.&lt;/EM&gt; or &lt;EM&gt;x.,&amp;nbsp;&lt;BR /&gt;&lt;/EM&gt;despite fact of existence&amp;nbsp;&lt;EM&gt;x\.&lt;/EM&gt; and &lt;EM&gt;x\.,&lt;/EM&gt; in regular expression before &lt;EM&gt;x&lt;/EM&gt;&lt;BR /&gt;Does anyone know how it could be fixed?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Resulted dataset:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;name&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;x., test&lt;/TD&gt;&lt;TD&gt;., test&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.x test&lt;/TD&gt;&lt;TD&gt;. test&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;test x.&lt;/TD&gt;&lt;TD&gt;test .&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired dataset:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;name&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;x., test&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.x test&lt;/TD&gt;&lt;TD&gt;. test&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;test x.&lt;/TD&gt;&lt;TD&gt;test&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 17 Nov 2021 08:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780503#M248709</guid>
      <dc:creator>Ga1ath</dc:creator>
      <dc:date>2021-11-17T08:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions: match dot and comma as characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780533#M248725</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399131"&gt;@Ga1ath&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see two issues:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A word boundary (PRX metacharacter &lt;FONT face="courier new,courier"&gt;\b&lt;/FONT&gt;) cannot occur directly after a comma or a period because by &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0s9ilagexmjl8n1u7e1t1jfnzlk.htm#n17bbcvf29v05in1reqrpd5lac6s" target="_blank" rel="noopener"&gt;definition&lt;/A&gt;&amp;nbsp;it is "&lt;SPAN&gt;the position between a word and a space" -- but neither the comma nor the period is a word character (cf. PRX metacharacter &lt;FONT face="courier new,courier"&gt;\w&lt;/FONT&gt;).&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;The "&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;\&lt;/STRONG&gt;x&lt;/FONT&gt;" in your regular expression should read "&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;|&lt;/STRONG&gt;x&lt;/FONT&gt;".&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN&gt;Try this regex instead:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;a=prxchange('s/\b(x\.,|x\.|x\b)//i', -1, name);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Nov 2021 19:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780533#M248725</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-11-16T19:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions: match dot and comma as characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780534#M248726</link>
      <description>&lt;P&gt;Is that last table supposed to be what you want to produce? Or is it the wrong output your current code is producing?&amp;nbsp; If the latter then please provide the desired results for your example input.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 19:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780534#M248726</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-16T19:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions: match dot and comma as characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780535#M248727</link>
      <description>&lt;P&gt;It is the wrong output. I'll edit the post.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 19:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780535#M248727</guid>
      <dc:creator>Ga1ath</dc:creator>
      <dc:date>2021-11-16T19:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions: match dot and comma as characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780539#M248729</link>
      <description>&lt;P&gt;Thank you for reply!&lt;BR /&gt;All clear except second issue. You'h wrote&amp;nbsp;&lt;EM&gt;The "&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;\&lt;/STRONG&gt;x&lt;/FONT&gt;" in your regular expression should read "&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;|&lt;/STRONG&gt;x&lt;/FONT&gt;".&amp;nbsp;&lt;BR /&gt;&lt;/EM&gt;But I don't see &lt;EM&gt;\x&amp;nbsp;&lt;/EM&gt;in my primordial regular expression. Please, can you explain what you have meant?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 19:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780539#M248729</guid>
      <dc:creator>Ga1ath</dc:creator>
      <dc:date>2021-11-16T19:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions: match dot and comma as characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780596#M248747</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399131"&gt;@Ga1ath&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;All clear except second issue. You'h wrote&amp;nbsp;&lt;EM&gt;The "&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;\&lt;/STRONG&gt;x&lt;/FONT&gt;" in your regular expression should read "&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;|&lt;/STRONG&gt;x&lt;/FONT&gt;".&amp;nbsp;&lt;BR /&gt;&lt;/EM&gt;But I don't see &lt;EM&gt;\x&amp;nbsp;&lt;/EM&gt;in my primordial regular expression. Please, can you explain what you have meant?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I meant this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/399131"&gt;@Ga1ath&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data want;
   set test;
   a=prxchange('s/\b(x\.,|x\.&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;\x&lt;/FONT&gt;&lt;/STRONG&gt;)\b//i', -1, name);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;whereas&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;a=prxchange('s/\b(x\.,|x\.&lt;STRONG&gt;&lt;FONT color="#008000"&gt;|x&lt;/FONT&gt;&lt;/STRONG&gt;\b)//i', -1, name);&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 16 Nov 2021 21:39:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780596#M248747</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-11-16T21:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Regular expressions: match dot and comma as characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780689#M248770</link>
      <description>&lt;P&gt;Of course, yeah. I'm sorry for my inattention.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 08:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Regular-expressions-match-dot-and-comma-as-characters/m-p/780689#M248770</guid>
      <dc:creator>Ga1ath</dc:creator>
      <dc:date>2021-11-17T08:25:59Z</dc:date>
    </item>
  </channel>
</rss>

