title: Regex if first match, then show results of second match
body: <p>I am trying to construct a regex pattern that will return the results of the second pattern if the first pattern is being matched. I am trying to use the special if/then/else construct, but it appears that if the <code>if</code> statement is true, the results are every single character and not the <code>then</code> pattern. How can i rewrite this regex so that it only returns the <code>then</code> matches if the <code>if</code> pattern is true? the <code>else</code> is not needed in this case. I am referring to this <a href="https://www.regular-expressions.info/conditional.html" rel="nofollow noreferrer">article</a>. Ultimate goal is to use this with <code>rg</code>. </p>
  
  <p><strong>EDIT</strong>: Updating my regex because <code>findme</code> is never next to <code>pattern</code> and i understand the mistake of my logic. I am still trying to match for <code>findme</code> if <code>pattern</code> does exist using the if/then logic</p>
  
  <p>My current regex is <code>(?(pattern)findme)</code> although i really prefer not to use lookaheads in this case. Regex101 is showing matching everything:</p>
  
  <p><a href="https://i.stack.imgur.com/N417n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N417n.png" alt="enter image description here"></a></p>
  
  <p>Sample text (contains both <code>pattern</code> and <code>findme</code>). There are two <code>findme</code>s. The line breaks in the sample text are intentional:</p>
  
  <pre><code>Sed ut perspiciatis unde omnis iste natus error 
  sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto
  beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit pattern aut fugit, sed quia consequuntur magni dolores eos findme qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed
  quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam,
  quis nostrum exercitationem findme ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequ
  atur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
  </code></pre>