|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles Qt Script for Applications

[Prev: Size] [Home] [Next: String]

RegExp

A RegExp is a regular expression matcher for strings.

Regular expressions can be created either by using the /expression/ syntax or by using the RegExp constructor as shown below. Note that when using the RegExp constructor, a string is passed, and all backslashes must be escaped using an extra backslash, i.e. \d. Below are two ways to create regular expressions that matches the pattern "QUANTITY=471 # Order quantity" and gets the number 471.

    var directRegex = /([A-Z]+)=(\d+)/;
    var str = "QUANTITY=471 # Order quantity";
    str.match(directRegex);
    directRegex.capturedTexts[2]; // "471";
        
    var indirectRegex = new RegExp( "([A-Z]+)=(\\d+)" );
RegExp Properties
RegExp Functions

[Prev: Size] [Home] [Next: String]


Copyright © 2001-2006 TrolltechTrademarks
QSA version 1.1.5