<?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: How to use regular expression to extract Name of a File and it's extension ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605558#M175770</link>
    <description>&lt;P&gt;Assuming that the file name consists of a numeric field followed by an underscore, and then an alphanumeric field, an underscore, and an alphabetic word:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
txt = "20191102_Registre_Distributions_isan.csv";
firstþart = prxchange("s/(\d+_)(\w+)_([a-z]+)\.csv/\2/io", 1, txt);
secondPart = prxchange("s/(\d+_)(\w+)_([a-z]+)\.csv/\3/io", 1, txt);
put (_all_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; txt=20191102_Registre_Distributions_isan.csv
 firstþart=Registre_Distributions
 secondPart=isan&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Nov 2019 22:24:30 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2019-11-19T22:24:30Z</dc:date>
    <item>
      <title>How to use regular expression to extract Name of a File and it's extension ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605482#M175738</link>
      <description>&lt;P&gt;Hi everyone , i have this file name:&lt;/P&gt;
&lt;P&gt;20191102_Registre_Distributions_isan.csv;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and i want to extract the first part which would be '&amp;nbsp;Registre_Distributions ' and the second part which would be ' isan '&amp;nbsp; , and i'm wondering how it could be achieved using the prxchange function.&lt;/P&gt;
&lt;P&gt;any help would be much appreciated , thank you .&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 18:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605482#M175738</guid>
      <dc:creator>Midi</dc:creator>
      <dc:date>2019-11-19T18:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regular expression to extract Name of a File and it's extension ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605483#M175739</link>
      <description>&lt;P&gt;To write a regular expression you need rules. What are the rules that describe how the filenames are constructed? And what parts you want to extract?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easiest would be if the string always consists of four parts separated by underscore. Then there would be no need for regular expressions at all. Simple SCAN() function will work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;first_part = catx(('_',scan(filename,2,'_'),scan(filename(3,'_'));
second_part = scan(filename,4,'_.');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 18:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605483#M175739</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-19T18:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regular expression to extract Name of a File and it's extension ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605558#M175770</link>
      <description>&lt;P&gt;Assuming that the file name consists of a numeric field followed by an underscore, and then an alphanumeric field, an underscore, and an alphabetic word:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
txt = "20191102_Registre_Distributions_isan.csv";
firstþart = prxchange("s/(\d+_)(\w+)_([a-z]+)\.csv/\2/io", 1, txt);
secondPart = prxchange("s/(\d+_)(\w+)_([a-z]+)\.csv/\3/io", 1, txt);
put (_all_) (=/);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; txt=20191102_Registre_Distributions_isan.csv
 firstþart=Registre_Distributions
 secondPart=isan&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Nov 2019 22:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605558#M175770</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-11-19T22:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regular expression to extract Name of a File and it's extension ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605576#M175775</link>
      <description>SCAN() is infinitely easier. &lt;BR /&gt;&lt;BR /&gt;file_name = scan (var_name, 1, ".");&lt;BR /&gt;ext = scan(var_name, 2, ".");&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Nov 2019 23:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-regular-expression-to-extract-Name-of-a-File-and-it-s/m-p/605576#M175775</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-19T23:16:26Z</dc:date>
    </item>
  </channel>
</rss>

