<?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: Reg expression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reg-expression/m-p/45547#M9422</link>
    <description>I'm guessing the MD|M.D. is optional, so your missing a ? after that (makes the preceding item optional).&lt;BR /&gt;
&lt;BR /&gt;
Add the ? (see under), then it should work fine for Dr. William Patterson.&lt;BR /&gt;
[pre]&lt;BR /&gt;
_EXPR='s/(Dr.)?(\s*\S*)\s*?\S*?(\s+)(\S*)\s*(MD|M.D.)?\s*/$2 $4/i';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Cheers from Portugal&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
    <pubDate>Fri, 22 Jan 2010 16:39:10 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2010-01-22T16:39:10Z</dc:date>
    <item>
      <title>Reg expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-expression/m-p/45546#M9421</link>
      <description>I used the following reg expression to separate the physicians name as first and last.&lt;BR /&gt;
_EXPR='s/(Dr.)?(\s*\S*)\s*?\S*?(\s+)(\S*)\s*(MD|M.D.)\s*/$2 $4/i';&lt;BR /&gt;
_REGX=prxparse(_EXPR);&lt;BR /&gt;
_PRX=prxchange(_REGX,1,name);&lt;BR /&gt;
* split parsed text into desired variables;&lt;BR /&gt;
physician_FIRST_name=scan(_PRX,1);&lt;BR /&gt;
physician_LAST_name=scan(_PRX,2);&lt;BR /&gt;
&lt;BR /&gt;
The above logic is not working for Dr. William Patterson.&lt;BR /&gt;
I',m getting physician_FIRST_name as Dr and physician_last_name as William.&lt;BR /&gt;
How to get William Patterson as first and last names.</description>
      <pubDate>Fri, 22 Jan 2010 16:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-expression/m-p/45546#M9421</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-01-22T16:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reg expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reg-expression/m-p/45547#M9422</link>
      <description>I'm guessing the MD|M.D. is optional, so your missing a ? after that (makes the preceding item optional).&lt;BR /&gt;
&lt;BR /&gt;
Add the ? (see under), then it should work fine for Dr. William Patterson.&lt;BR /&gt;
[pre]&lt;BR /&gt;
_EXPR='s/(Dr.)?(\s*\S*)\s*?\S*?(\s+)(\S*)\s*(MD|M.D.)?\s*/$2 $4/i';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Cheers from Portugal&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Fri, 22 Jan 2010 16:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reg-expression/m-p/45547#M9422</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-01-22T16:39:10Z</dc:date>
    </item>
  </channel>
</rss>

