title: Java text filter
body: <p>For a project I need to develop een Java application which checks a string on multiple parts:</p>
  
  <ol>
  <li>First a text check if the word contains a word of a specified list.<br>
  Keep reminded that:
  
  <ul>
  <li>It is possible that the input can contain a word of the list but there can be spaces or special characters can be put in between characters to bypass the filter. In that case the filter needs to filter the word to.</li>
  <li>It is possible that the word can be placed in another word. Then the word needs to be filtered if list the before and/or after filter is specified. </li>
  </ul></li>
  <li>Second is filtering the text if it contains an ip address.<br>
  Keep reminded that:
  
  <ul>
  <li>It is possible that the input can contain an ip where speciale characters or spaces are used to bypass the filter. In that case the filter needs to filter the ip address to.</li>
  </ul></li>
  <li>As third is filtering web addresses from the text.<br>
  Also here keep reminded that:
  
  <ul>
  <li>It is possible that the input can contain an web address where special characters or spaces are used to bypass the filter. In that case the filter needs to filter the web address to.</li>
  </ul></li>
  </ol>
  
  <p>I tested some idea's with checking on spaces and speciale characters, but it cost a lot of work to proces the incoming text. </p>
  
  <p>An example of what i tried:</p>
  
  <pre><code>public static boolean validateBericht(String msg) {
      return validateTransformedBericht(msg);
  }
  
  private static boolean validateTransformedBericht(String bericht) {
      if (bericht.length() != 0) {
          for (String woord : ChatControlList.getChatControlList()
                  .getWoordenLijst()) {
              for (int i = 0; i &lt; (bericht.length() - (woord.length() - 1)); i++) {
                  if (i == 0 || inTekenLijst(bericht.charAt(i))) {
                      int index = 0;
                      for (int j = i; j &lt; bericht.length(); j++) {
                          if (inTekenLijst(bericht.charAt(j))) {
                          } else if (bericht.charAt(j) == woord.charAt(index)) {
                              index++;
                          } else {
                              break;
                          }
                          if (index == woord.length()) {
                              if ((bericht.length() - 1) == j
                                      || inTekenLijst(bericht.charAt(index))) {
                                  return true;
                              } else {
                                  break;
                              }
                          }
                      }
                  }
              }
          }
      }
      return false;
  }
  
  private static boolean inTekenLijst(char teken) {
      for (String tekenUitLijst : ChatControlList.getChatControlList()
              .getSpecialeTekens()) {
          if (tekenUitLijst.equalsIgnoreCase(String.valueOf(teken))
                  || String.valueOf(teken).equalsIgnoreCase(" ")) {
              return true;
          }
      }
      return false;
  }
  </code></pre>
  
  <p>Has someone any idea how to solve it on a good working solution?</p>
  
  <p>Harm</p>