title: SAS: Parsing a string/character value looking for multiple delimiters
body: <p>I am trying to find a way to parse rather long strings of text. I want to extract a substring between certain words in the string. Below is an example of the kind of text I am looking at:</p>
  <pre><code>String1 = &quot;Report failed: FailType: FailLevel, FailDate 12.01.2016. InstanceType (name_of_type) -9234as-df32f-2f2f Error : Error_message1. Error : Error_message2. Error : Error_message3.&quot; 
  String2 = &quot;Report failed: FailType: FailLevel, FailDate 12.01.2016. InstanceType (name_of_type) -zx3s-d2f-211 Error : Error_message1. Error : Error_message2.&quot; 
  </code></pre>
  <p>I would like to parse the string and create columns looking something like this:</p>
  <pre><code>Obs# | ErrorType1      | ErrorType2      | ErrorType3
    1  | Error_message1  | Error_message2  | Error_message3  
    2  | Error_message1  | Error_message2  | 
  </code></pre>
  <p>So different numbers of errors for each string.</p>
  <p>I have updated my current progress with the problem based on the initial two comments below:</p>
  <pre><code>If _N_ = 1 Then Pattern = Prxparse(&quot;/ Error /&quot;);
  Retain Pattern;
  </code></pre>
  <pre><code>Position = prxmatch(Pattern, Strings);
  Substring = substr(Strings, Position);
  </code></pre>
  <p>This does give me the entire substring after the first occurence of the word &quot; Error &quot; - the blank spaces are intentional. However, I fail to create a loop or search for all occurences of the string ' Error '. I had something like this in mind.</p>
  <pre><code>    if prxmatch(Pattern, Strings) then
      do;
          String1 = prxposn(Pattern, 1, Strings);
          String2 = prxposn(Pattern, 2, Strings);
      end;
  </code></pre>
  <p>But based on my results (String1 and String2 are empty), it is clear I lack understanding of the prxposn function. I just found the PRXNEXT function, and would like to give this a go. Not sure yet how to get only a single error message at a time.</p>
  <p>Best regards!</p>