regexp
function that allows a regular expression to be applied to a string and a boolean result returned. However JoSQL has NO native support for regular expressions, instead of arbitrarily selecting an implementation the decision was made to support ALL implementations and leave it to the developer to select the implementation that they prefer and use that. Also, selecting a particular implementation would also vastly increase the size of the download which is undesirable (not to mention potential licensing conflicts since most are LGPL/GPL and JoSQL uses an Apache license).JoSQL does have support for a number of the "standard implementations" if they are available in the CLASSPATH. The supported implementations are (in no particular order):
Name | Supported Version | JoSQL Instance Name |
ORO | 2.0.8 | oro |
Java (java.util.regex) | 1.4+ | java |
Apache RegExp | 1.3 | apache.regexp |
GNU RegExp | 1.1.4 | gnu |
Two functions are provided to allow developers access to the regular expression functionality:
regexp (Object, String)
and regexp (Object, String, String)
. The first function uses the "default" implementation, if that implementation is not available (you are using a Java version less than 1.4) then JoSQL will look for any of the other "standard" implementations, if none of them are available then an exception will be thrown by the function indicating that the library isn't available. The second function allows the developer to specify the implementation to use by using one of the JoSQL Instance Name strings defined in the table above.For example:
/* Use the default regular expression library. */ SELECT * FROM java.lang.Object WHERE regexp (class.name, 'java.*Object') /* Use a named regular expression library */ SELECT * FROM java.lang.Object WHERE regexp (class.name, 'java.*Object', 'gnu') /* You can even used different regular expression libraries for different calls to "regexp"! */ SELECT * FROM java.lang.Object WHERE regexp (class.name, 'java.*Object', 'gnu') AND regexp (class.name, 'java.*Object', 'java') AND regexp (class.name, 'java.*Object', 'oro')