<?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: End of line anchor in regular expression does not seem to work in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430003#M106249</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;This is because of trailing spaces :&lt;BR /&gt;prxmatch('m/^f.*r$/i', strip(a))</description>
    <pubDate>Tue, 23 Jan 2018 14:40:02 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2018-01-23T14:40:02Z</dc:date>
    <item>
      <title>End of line anchor in regular expression does not seem to work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430000#M106247</link>
      <description>&lt;P&gt;I don't think the functionality of the "$" symbol in regular expressions works in SAS.&amp;nbsp; The code I'm using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data foo;
	input a :$1024.;
	datalines;
foobar
barfoo
food
westchester
freebeer
;
run;

proc sql;
	create table test as 
	select *
	from foo
	where prxmatch('m/^f.*r$/i', a);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I expect test to return "foobar" and "freebeer" however it returns an empty set.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 14:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430000#M106247</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-01-23T14:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: End of line anchor in regular expression does not seem to work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430003#M106249</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;This is because of trailing spaces :&lt;BR /&gt;prxmatch('m/^f.*r$/i', strip(a))</description>
      <pubDate>Tue, 23 Jan 2018 14:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430003#M106249</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-01-23T14:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: End of line anchor in regular expression does not seem to work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430005#M106251</link>
      <description>&lt;P&gt;OK, that seems to work.&amp;nbsp; I'm a bit confused about the syntax here.&amp;nbsp; I thought adding the ":" made the data type like a vary character with a maximum of 1024?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also when I use this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table test as 
	select length(a)
	from foo;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I don't see length of any additional whitespace added.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table test as 
	select put(a, $hex16.)
	from foo;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I see the ASCII symbol for a space.&amp;nbsp; I take it SAS doesn't count white space in the length calculation?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 14:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430005#M106251</guid>
      <dc:creator>tomcmacdonald</dc:creator>
      <dc:date>2018-01-23T14:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: End of line anchor in regular expression does not seem to work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430013#M106257</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/142145"&gt;@tomcmacdonald&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;As documented the SAS function LENGTH() returns the length of a string up to the last non-blank character. In SAS Foundation version 9.x all character variables are of type CHAR. VARCHAR doesn't exist. That's why you've got most of the time trailing blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For RegEx: Either TRIM() or STRIP() the variable or then add the potential trailing blanks to your RegEx using &lt;FONT face="courier new,courier"&gt;\s*$&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 15:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/End-of-line-anchor-in-regular-expression-does-not-seem-to-work/m-p/430013#M106257</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-01-23T15:07:03Z</dc:date>
    </item>
  </channel>
</rss>

