I need a Regular Expression to match a sequence of characters that make up a query. An example of my definition of a query is like this : **and(cat,dog)** In a more general definition, it can be represented as ***operator(operand, operand)*** It is made up of an operator that contains 2 operands. The operands can be any single ALPHABETIC word(non-numeric) or even another subquery. and an example is **and(goat,or(zebra,bear))** The operators are **AND, OR, NOT** and a query can get more and more **AMBIGUOUS** to an extent as far as possible. There is no **WHITESPACE** within the query and I need the regex to use in a Java application. Note: A **NOT** operator can have only one operand e.g. **not(tiger)**. Thanks in advance.