Regex (query directive)
Filters and/or performs search and replace operations using regular expressions.
Directive can optionally be given a mode parameter which is a bit-wise or of several different options. Available options are Regex.MODE_MATCH, Regex.MODE_GLOBAL and Regex.MODE_ICASE. The MATCH option causes the directive to return an empty result if no match is found. Otherwise rows are returned as is if no match is found. The GLOBAL option causes the regular expression to be matched against the whole input. Otherwise it is sufficient that part of the input matches. The ICASE option causes matching to be performed ignoring case.
If a replacement string is given, any matches are replaced with that. Otherwise no replacement is performed and the directive is used only to filter rows. Replacement cannot be used when directive is used as a filtering directive.
Regex(String regex,String replace,int mode)
Regex(String regex,String replace) - Uses mode global
Regex(String regex) - Uses mode match and global
Regex(String regex,int mode) - Uses the specified mode but forcing match option
Regular expression syntax is described in Java Pattern class documentation
importPackage(org.wandora.query2); new BaseName().from( new Instances() ).where( new Regex(".*type.*") )
This selects all base names of the instances of the input topic which contain the word "type".