Using Regular Expressions in Search
Numerical Comparisons
You can use the following operators for numerical comparisons:
| Operator | Meaning |
| = | Equal to |
| != | Not equal to |
| > | Greater than |
| >= | Greater than or equal to |
| < | Less than |
| <= | Less than or equal to |
Examples:
| If you want to search for records where this field... | Use the following syntax in the field | Comments |
| Contains a numerical value less than x | < x | To search for an item that has a unit price less than $10, type the following in the Unit Price field: < 10 |
| Contains a numerical value not equal to x | != x | To search for an item that has a quantity other than 20, type the following in the Quantity field: != 20 |
XQuery Sequence Expressions
You can also use the xquery sequence expressions to search for records. XQuery sequence expressions do not require the =~ (equal tilde). The following XQuery Sequence Expressions can be used:
| If you want to search for records where this field... | Use the following syntax | Comments |
| Contains a number in a range | = (lowrange_number to highrange_number) | To search for an item that has a unit price between $15 and $50, type the following in the Unit Price field: = (15 to 50) |
| Contains one of a list of values | = ("value1", "value2", "value3") | To search for Berkeley, San Diego, or Tucson in a City field, type the following in the City field: = ("Berkeley", "San Diego", "Tucson") |
Regular Expressions
You can use regular expressions to search for records. Regular Expressions describe a pattern to match -- a sequence of characters, not words -- within a line of text. Use the symbols =~ (equal tilde) to indicate that you want to use regular expressions in your search parameter(s). Note that regular expressions are case sensitive.
For example, to search for an incident in the Incidents that has the word “Tires” anywhere in the Description, you would type “=~Tires” in the Description field in the Search form for the Items Collection. To search for all records with "Tires" or "tires" you would type "=~(Tires|tires)" or equivalently "=~[Tt]ires". See below for a detailed explanation and more examples.
Common Search Examples using Regular Expressions
If you want to search for records where this field... | Use the following syntax | Comments |
Contains 'Text' (anywhere in the field) | =~Text | This expression will match "Text","Textile", "subText", etc. |
Starts with 'Text' | =~^Text.* or =~^Text | The carat means start of line or field. This expression will match "Text","Textile", etc. at the start of the field only |
Ends in 'tion' | =~tion$ | Matches "construction" but not "air conditioning" |
Contains 'Text' or 'text' | =~[Tt]ext or =~(Text|text) | Matches "Textile", "context" |
Contains only "Text" | "Text" (literal string) or, using Regular Expression: =~^Text$ | Matches only "Text". |
Contains either "screw" or "nail" | =~(screw|nail) | Matches either "screw" or "nail" |
Summary of Regular Expression Syntax
The most commonly used regular expression examples and syntax supported by the application are provided in the table below. Remember to include the =~ before the regular expression character.
To learn more about regular expressions please go to http://en.wikipedia.org/wiki/Regular_expression
| Character | Meaning | Example |
| . | Match any single character | =~do. would match "dog", "dot", "doe", etc. |
| * | Match a sequence with zero or more instances of the previous pattern | To find sequence where "do" followed by zero or more of any character, type: =~do.* This would match "dog", "done", "doppleganger", etc. Other examples: "=~to*" would match "to" and "too" ("t-o- followed by zero or more o's") |
+ | Match a sequence with at least one instance of the previous pattern. | =~fre+.. would match "freak", "freeze", "fresh" ("f-r- followed by one or more e's followed by any two characters) |
| ? | Match a sequence with at most one instance of the previous pattern. (0 or 1 occurrence of the previous pattern) | =~ton?e would match "toe" and "tone" ( "t-o- followed by zero or one n followed by e") |
| [ ] | Match any one of the enclosed characters, as in [aeiou]. Use Hyphen "-" for a range, as in [0-9]. | =~to[oew] would match "toe", "too", and "tow" but not "ton" |
| [^ ] | Match any one character except those enclosed in [ ], as in [^0-9]. | =~to[^w] would would match "toe", "too", and "ton" but not "tow" |
| \{x,y\} | Match x to y occurrences of the preceding | =~.{5, 15} would match strings that are at least 5 and atmost 15 characters long |