title: combine two java regex
body: <p>Having to use regex for the first time and although I almost achieved what I require I do not seems to be able to combine into a single statement.</p>
  
  <p>I have a string of words where I wish to replace <code>\n</code> if it is not preceded by a dot OR not preceded by a dot space.</p>
  
  <p>I can run either of these two statements to achieve the required result. However, if I either run them one after another or try to combine them into a single regex, it does not work.</p>
  
  <pre class="lang-java prettyprint-override"><code>//replaces \n if not preceded by dot space
  xx = xx.replaceAll("(.+)(?&lt;!\\. )\n", "$1 ");
  
  
  //replaces \n if not preceded by dot
  xx = xx.replaceAll("(.+)(?&lt;!\\.)\n", "$1 "); 
  
  
  //one of my attempts to combine into a single statement
  xx = xx.replaceAll("(.+)(?&lt;!\\. )\n|(?&lt;!\\.)\n", "$1 ");
  </code></pre>
  
  <p>Example of String I'm trying to fix.</p>
  
  <p>BEFORE</p>
  
  <pre>
  This is some text which may\n
  have a newline character to break the line\n
  but I only want to remove it if it's not preceded with a full.\n
  or it's not preceded with a full stop and a space. \n
  </pre>
  
  <p>AFTER</p>
  
  <pre>
  This is some text which may
  have a newline character to break the line 
  but I only want to remove it if it's not preceded with a full.\n
  or it's not preceded with a full stop and a space. \n
  </pre>
  
  <p>I think I'm close, but being new to regex, I am getting more confused the more I read.</p>