title: Regular Expression Solution in Java
body: <p>i am new on Regular Expression.</p>
  
  <p>I will test a String, wheter it is valid with a regular expression.</p>
  
  <p>MY String is following:</p>
  
  <pre><code>`Select * from xddf_db.yyy_tte where adress = '[PARAM]' and surename like '%[ABC]'` .... can several times on the end with and/or
  </code></pre>
  
  <p>It can begin als with Select name must not with *</p>
  
  <pre><code>`Select Name` .....
  </code></pre>
  
  <p>The important is that the bracket fields should begin and end with '[sdf]' or never with apostroph for exampe [sdf] that is correct too. But it is not allowed to begin with apostroph and not end. For example  '[asd] That should wrong. </p>
  
  <p>The underline charcters "_" can in it but not must.</p>
  
  <p>It is correct between/ Or not with apostroph. The fields can have have one percent symbol(it is for Like function).  For Example it is correct '%[asd]' or  %[asd]&amp; correct toobe . That is correct too '[asd]%'  but that is wrong:  '%%[sdđ]%' . Only one it is allowed.  I hope you can help we with this hard expression. </p>
  
  <hr>
  
  <p>Here is the list:</p>
  
  <p>Allowed:</p>
  
  <pre><code>Select * from xddf_db.yyy_tte where adress = '[PARAM]' and surename like '%[ABC]'
  Select * from xddf_db.yyy_tte where adress = '[PARAM]' and surename like '%[ABC]&amp;'
  Select * from xddf_db.yyy_tte where adress = '[PARAM]' and surename like '[ABC]&amp;'
  Select Name from xddfdb.yyy where adress = '[PARAM]' and surename_abc ='[ABC]'
  Select Name from xddfdb.yyy where adress = '[PARAM]' and surename_abc =[ABC]
  Select * from xddfdb.yyy_tte where adress = '[PARAM]' and surename_abc =[ABC]
  Select * from xddfdb.yyy_tte where adress = '[PARAM]' and surename_abc =[ABC] or post_dd like '%[ABC]'
  Select * from xddfdb.yyy_tte where adress = '[PARAM]' and surename_abc =[ABC] or post_dd &lt; [ABC] and post_dd &gt; [ABD]
  </code></pre>
  
  <p>WRONG</p>
  
  <pre><code>Select * from xddfdb.yyy_tte where adress = [PARAM]' and surename_abc = '[ABC]
  Select * from xddf_db.yyy_tte where adress = '[PARAM]' and surename like '%[ABC]&amp;&amp;'
  Select Name from xddf_db.yyy_tte where adress = '[PARAM]' and surename like '%&amp;[ABC]&amp;&amp;'
  </code></pre>