Regular Expressions in Q1


Q1 allows the use of regular expressions in most of the places where a string comparison is required (for example when searching a list item by name or a window by its title). You can specify you want to use a regular expression match by prefixing the pattern with the backslash character (\). Note that the syntax of some script languages (for example JScript) allows backslash characters in strings only if they are escaped by a second backslash ("\\" = "\").

// This will search for an item whose value equals 'a*b'
var item1 = listbox.findItem("a*b");

// This will search for an item whose value equals 'b', 'ab', 'aab' and so on
var item2 = listbox.findItem("\\a*b");
		

Syntax

Regular expressions allow a great deal of flexibility when working with strings, but it may take some time to get used to their syntax, that is if they are not already familiar to you.

A regular expression pattern describes how a string should look in order to be considered a valid match. It is composed of string literals (letters and numbers) together with escape characters which define matching rules:

 


© 2003 Lightweight Technologies. All rights reserved.
© 1998-2001 Dr John Maddock.
Regular expression support and documentation is provided under the following terms: "Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Dr John Maddock makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty."