Regex (query directive)

From WandoraWiki
(Difference between revisions)
Jump to: navigation, search
 
Line 19: Line 19:
 
== Notes ==
 
== Notes ==
  
Regular expression syntax is describe in [http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html Java Pattern class documentation]
+
Regular expression syntax is described in [http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html Java Pattern class documentation]
  
 
== Examples ==
 
== Examples ==

Latest revision as of 13:54, 26 August 2009

Contents

[edit] Description

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.

[edit] Constructor

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

[edit] Notes

Regular expression syntax is described in Java Pattern class documentation

[edit] Examples

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".

Personal tools