UCanAccess uses HSQLDB as a support database, so we can use the HSQLDB REGEXP_MATCHES() function in UCanAccess queries for Access databases. For example, the following query searches for Canadian postal codes (for example, "A1B 2C3") ...
ResultSet rs = stmt.executeQuery( "SELECT PostalCode FROM Members " + "WHERE REGEXP_MATCHES(PostalCode, '^[a-zA-Z]\\d[a-zA-Z] \\d[a-zA-Z]\\d$')";
... although, as Marco points out in his answer , UCanAccess also supports SQL Access functions, like regular expressions, in a LIKE expression that can be used to accomplish the same thing.
In addition, with UCanAccess, we can use the REGEXP_SUBSTRING() function from HSQLDB to actually extract text from a column based on a template. The following code retrieves the first substring from [TextField], which looks like the North American phone number (for example, "416-555-1212" or "403-GOT-BEEF"):
ResultSet rs = stmt.executeQuery( "SELECT phone " + "FROM " + "( " + "SELECT REGEXP_SUBSTRING(TextField, '\\d{3}-\\w{3}-\\w{4}') AS phone " + "FROM Table1 " + ") " + "WHERE phone IS NOT NULL");
source share