Parsing the Logical expression
Sometimes you need to parse the logical expression. I have made for my own purposes the regular expression which would distringuish all important tokens from the logical expression: ([\(!\s]*)[\s]*([^<=\s]+)[\s]*(<>|!=|==|<=|>=|<|>)[\s]*([^\s&|\)]*)[\s]*([\)]*)(&&|\|\|)? or as java string: "([\\(!\\s]*)[\\s]*([^<=\\s]+)[\\s]*(<>|!=|==|<=|>=|<|>)[\\s]*([^\\s&|\\)]*)[\\s]*([\\)]*)(&&|\\|\\|)?" this would give for !(! (one== 56) && two>45) || !three!=funny the following solution Regular Expression ([\(!\s]*)[\s]*([^<=\s]+)[\s]*(<>|!=|==|<=|>=|<|>)[\s]*([^\s&|\)]*)[\s]*([\)]*)(&&|\|\|)? as a Java string "([\\(!\\s]*)[\\s]*([^<=\\s]+)[\\s]*(<>|!=|==|<=|>=|<|>)[\\s]*([^\\s&|\\)]*)[\\s]*([\\)]*)(&&|\\|\\|)?" Replacement $1fieldValue(\"$2\")$3$4$5$6 groupCount() 6 ...