RegExp

Summary

Represents regular expressions.

Description

System.RegExp represents regular expressions.

The System.RegExp class provides utilities for matching text with a regular expression pattern.

Regular expression literals are created with forward slashes (/) at the beginning and end of a regular expression pattern. An empty regular expression can be created using an empty capturing group:

/(?:)/

By default, JS++ supports the ECMAScript 3 flavor of regular expressions.

Differences to JavaScript

exec has been fixed to properly support the "g" (global match) flag and will return an empty array instead of null if there are no matches.

Warning

Regular expressions should generally not be used for parsing HTML, XML, or programming language source code. Use an appropriate parser instead of regular expressions to handle these.

Examples

Instantiation
1
2
3
import System;
 
System.RegExp re = new System.RegExp(/.+/);
Auto-boxing
1
2
3
import System;
 
System.RegExp re = /.+/;

Methods

  • exec

    Matches the regular expression pattern against some text and returns an array of matches.

  • flags

    Returns the flags for the regular expression.

  • global

    Returns whether the regular expression will perform a global match.

  • ignoreCase

    Returns whether the regular expression will perform a case-insensitive match.

  • lastIndex

    Sets or retrieves the last index for a global match.

  • multiline

    Returns whether the regular expression will perform a multi-line match.

  • RegExp (Constructor)

    Constructs a System.RegExp object with the specified regular expression pattern and flags.

  • source

    Returns the regular expression pattern.

  • test

    Matches the regular expression pattern against some text and returns a Boolean representing whether the match succeeded.

  • toString

    Returns a string representation of the regular expression value.

  • valueOf

    Returns the primitive regular expression value wrapped by the System.RegExp object.

Share

HTML | BBCode | Direct Link