title: How to write a regex OR statement within strapply in R
body: <p>I have been using strapplyc in R to select different portions of a string that match one particular set of criteria.  These have worked successfully until I found a portion of the string where the required portion could be defined one of two ways.</p>
  
  <p>Here is an example of the string which is liberally sprinkled with \t:</p>
  
  <pre><code>\t\t\tsome words here\t\t\tDefect: some more words here Action: more words
  </code></pre>
  
  <p>I can write the strapply statement to capture the text between Defect: and the start of Action:</p>
  
  <pre><code>strapplyc(record[i], "Defect:(.*?)Action")
  </code></pre>
  
  <p>This works and selects the chosen text between Defect: and Action.  In some cases there is no action section to the string and I've used the following code to capture these cases.</p>
  
  <pre><code>strapplyc(record[i], "Defect:(.*?)$")
  </code></pre>
  
  <p>What I have been trying to do is capture the text that either ends with Action, or with the end of the string (using $).</p>
  
  <p>This is the bit that keeps failing.  It returns nothing for either option.  Here is my failing code:</p>
  
  <pre><code>strapplyc(record[i], "Defect:(.*?)Action|$")
  </code></pre>
  
  <p>Any idea where I'm going wrong, or a better solution would be much appreciated.</p>