title: Regex to find a valid URL in a email body regardless of newlines dividing it, and it need to contains '?' character
body: <p>I need a regex to find a valid URl in a email body, but only if exists a '?' in the match.</p>
  
  <p>ex:</p>
  
  <ul>
  <li>www.example.com.br/area?key=235fksf&amp;rec=fsjgsg (OK)</li>
  <li>www.example.com.br/area?key=235fksf (OK)</li>
  <li>www.example.com.br/area (Not OK)</li>
  </ul>
  
  <p>Thanks</p>
  
  <p>Edit: I discovered some emails that are dividing the URL with a new line "\r\n".</p>
  
  <p>PS: I'm using the site <a href="https://regex101.com/" rel="nofollow noreferrer">https://regex101.com/</a> to make some tests, but it's not working like I discribed.</p>
  
  <p>Edit:</p>
  
  <h2>Final Solution</h2>
  
  <p>To resolve the possible newline, I used the Hector's answer, and just modified to do what I needed.</p>
  
  <pre><code>var matches = Regex.Matches(body, @"(http(s)?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w-;,.\/?%&amp;=]*[\r\n]*[\w-;,.\/?%&amp;=]*)?");
  var url = string.Empty;
  
  foreach(Match match in matches)
  {
      if(match.Value.Contains('?'))
      {
          var matchSplit = match.Value.Split(Environment.NewLine.ToCharArray());
  
          foreach(var matchUnit in matchSplit)
          {
              //Is a valid piece?
              if (matchUnit.Any(x =&gt; @"/?&amp;=".Contains(x)))
                  url += matchUnit;
          }
          break;
      }
  }
  </code></pre>