<?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: PRXCHANGE to extract text outside of pipe | chars Regex not working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901543#M356279</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data input_data;
Length string $100. desiredresult $100.;
Infile datalines delimiter='#';
  input string $ desiredResult $;
  datalines;
match all of this|not this|match|no|yes|n|y#match all of this match yes y
;
run;
data input_data;
SET WORK.input_data;
string2 = PRXCHANGE('s/\|.*?\|/ /',-1,string);
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 04 Nov 2023 10:04:11 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-11-04T10:04:11Z</dc:date>
    <item>
      <title>PRXCHANGE to extract text outside of pipe | chars Regex not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901433#M356247</link>
      <description>&lt;P&gt;I'm trying to use RegEx to extract/transform a string column. I want to eliminate anything enclosed by a pipe character.&amp;nbsp; the regular expression below was tested in an editor regexr.com as shown:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASAlex101_0-1699025138052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89376i646369EC1B494261/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASAlex101_0-1699025138052.png" alt="SASAlex101_0-1699025138052.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I code this in SAS, I get no result in String2.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data input_data;
Length string $100. desiredresult $100.;
Infile datalines delimiter='#';
  input string $ desiredResult $;
  datalines;
match all of this|not this|match|no|yes|n|y#match all of this match yes y
;
run;
data input_data;
SET WORK.input_data;
string2 = PRXCHANGE('[^| ]*(?=(?:[^|]*\|[^|]*\|)*[^|]*$)',-1,string);
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89378i671814AEDFF8939E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; I'm not sure what I'm doing wrong here? seems simple enough. any ideas?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 18:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901433#M356247</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2023-11-03T18:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE to extract text outside of &lt;&gt; chars Regex not working [closed]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901446#M356253</link>
      <description>&lt;P&gt;Let's start with the subject line: PRXCHANGE to extract text outside of &amp;lt;&amp;gt; chars Regex not working [closed]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;None of your code or example text shows and &amp;lt; or &amp;gt; so I am not sure how your subject line actually relates to your shown code, or example pictures.&lt;/P&gt;
&lt;P&gt;It isn't even clear to me which is the desired resulting value of the variable sting2. Or the actual rule that may be involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/390253"&gt;@SASAlex101&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to use RegEx to extract/transform a string column. I want to eliminate anything enclosed by a pipe character.&amp;nbsp; the regular expression below was tested in an editor regexr.com as shown:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASAlex101_0-1699025138052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89376i646369EC1B494261/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASAlex101_0-1699025138052.png" alt="SASAlex101_0-1699025138052.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I code this in SAS, I get no result in String2.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data input_data;
Length string $100. desiredresult $100.;
Infile datalines delimiter='#';
  input string $ desiredResult $;
  datalines;
match all of this|not this|match|no|yes|n|y#match all of this match yes y
;
run;
data input_data;
SET WORK.input_data;
string2 = PRXCHANGE('[^| ]*(?=(?:[^|]*\|[^|]*\|)*[^|]*$)',-1,string);
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89378i671814AEDFF8939E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; I'm not sure what I'm doing wrong here? seems simple enough. any ideas?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 17:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901446#M356253</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-03T17:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE to extract text outside of &lt;&gt; chars Regex not working [closed]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901460#M356259</link>
      <description>sorry about that. I corrected the post and content. &lt;BR /&gt;</description>
      <pubDate>Fri, 03 Nov 2023 18:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901460#M356259</guid>
      <dc:creator>SASAlex101</dc:creator>
      <dc:date>2023-11-03T18:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE to extract text outside of pipe | chars Regex not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901492#M356263</link>
      <description>&lt;P&gt;Here you go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=prxchange('s/(\|[^|]*\|)/ /',-1,string);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Nov 2023 20:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901492#M356263</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2023-11-03T20:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE to extract text outside of pipe | chars Regex not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901496#M356265</link>
      <description>&lt;P&gt;Since the REGEX you tried is clearly not valid for SAS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;520  data input_data;
521  SET WORK.input_data;
522  string2 = PRXCHANGE('[^| ]*(?=(?:[^|]*\|[^|]*\|)*[^|]*$)',-1,string);
523  ;
524  run;

ERROR: Invalid characters "*(?=(?:[^|]*\|[^|]*\|)*[^|]*$)" after end delimiter "]" of regular expression "[^|
       ]*(?=(?:[^|]*\|[^|]*\|)*[^|]*$)".
ERROR: The regular expression passed to the function PRXCHANGE contains a syntax error.
NOTE: Argument 1 to function PRXCHANGE('[^| ]*(?=(?:'[12 of 35 characters shown],-1,'match all of'[12 of 100 characters shown]) at
      line 522 column 11 is invalid.
string=match all of this|not this|match|no|yes|n|y desiredresult=match all of this match yes y string2=  _ERROR_=1 _N_=1
NOTE: There were 1 observations read from the data set WORK.INPUT_DATA.
NOTE: The data set WORK.INPUT_DATA has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;Perhaps you should EXPLAIN what the rule is from transforming&lt;/P&gt;
&lt;PRE&gt;match all of this|not this|match|no|yes|n|y&lt;/PRE&gt;
&lt;P&gt;into&lt;/P&gt;
&lt;PRE&gt;match all of this match yes y&lt;/PRE&gt;
&lt;P&gt;You seem to have replaced | with spaces.&lt;/P&gt;
&lt;P&gt;But why did you remove "not this"?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 21:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901496#M356265</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-03T21:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: PRXCHANGE to extract text outside of pipe | chars Regex not working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901543#M356279</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data input_data;
Length string $100. desiredresult $100.;
Infile datalines delimiter='#';
  input string $ desiredResult $;
  datalines;
match all of this|not this|match|no|yes|n|y#match all of this match yes y
;
run;
data input_data;
SET WORK.input_data;
string2 = PRXCHANGE('s/\|.*?\|/ /',-1,string);
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Nov 2023 10:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PRXCHANGE-to-extract-text-outside-of-pipe-chars-Regex-not/m-p/901543#M356279</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-11-04T10:04:11Z</dc:date>
    </item>
  </channel>
</rss>

