by Raghuraja.C (12 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 3rd April 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Quick Reference
Microsoft Scripting Run-time Library Features
Collections Drivers, Files, Folders
Data Storage Dictionary
Dictionary Add, Exists, Items, Keys, Remove, RemoveAll, Count,
Item, Key
File System Drive, File, FileSystemObject, Folder, TextStream,
FileSystemObject, BuildPath, CopyFile, CopyFolder,
CreateFolder, CreateTextFile, DeleteFile, DeleteFolder,
DriveExists, FileExists, FolderExists, GetAbsolutePathName,
GetBaseName, GetDrive, GetDriveName, GetFile,
GetExtensionNameGetFileName, GetFolder, GetParentFolderName,
GetSpecialFolder, GetTempName, MoveFile, MoveFolder, OpenTextFile
Drivers, Drive, Drives, AvailableSpace, Count,
DriveLetter, DriveType, FileSystem, FreeSpace,
IsReady, Item, RootFolder, SerialNumber, TotalSize,
VolumeName
File, Files Add, Attributes, Copy, Delete, Move, Count,
Folder, Folders OpenAsTextStream, DateCreated, DateLastAccessed,
DateLastModified, Drive, Item, ParentFolder, Name,
Path, Size, ShortName, ShortPath
TextStream Close, Skip, SkipLine, Read, ReadAll, ReadLine
Write, WriteBlankLines, WriteLine, AtEndOfLine,
AtEndOfStream, Column, Line
VBScript Features
Array handling Array Dim, Private, Public, ReDim
IsArray, Erase, Lbound, Ubound
Assignments Set
Comments Comments Using ’ or Rem
Constants/Literal Empty, Nothing, Null, True, False
Control Flow Do..Loop, For..Next, For Each..Next
If..Then..Else, Select Case
While..Wend, With
Conversions Abs, Asc, AscB, AscW, Chr, ChrB, ChrW
Cbool, Cbyte, CCur, Cdate,
CDbl, Cint, CLng, CSng, CStr
DateSerial, DateValue, Hex, Oct , Fix, Int.
Sgn, TimeSerial, TimeValue
Date/Times Date, Time, DateAdd, DateDiff, DatePart
DateSerial, DateValue, Day, Month, MonthName
Weekday, WeekdayName, Year
Hour, Minute, Second, Now, TimeSerial, TimeValue
Declarations Class, Const, Dim, Private, Public, ReDim
Function, Sub, Property Get, Property Let,
Property Set
Error Handling OnError, Err
Expressions Eval, Execute, RegExp, Replace, Test
Formatting String FormatCurrency, FormatDateTime
FormatNumber, FormatPercent
Input/Output InputBox, LoadPicture, MsgBox, Literals, Empty
False, Nothing, Null, True
Math Atn, Cos, Sin, Tan, Exp, Log, Sqr, Randomize, Rnd
Miscellaneous Eval Function, Execute Statement, RGB Function
Objects CreateObject, Err Object, GetObject, RegExp
Operators +, -, ^, Mod, *, /, \, Negation (-), Str Concat (&)
=, <>, <, <=, >, >=, Is, And, Or, Xor, Eqy, Imp
Options Option Explicit
Procedures Call, Function, Sub, Property Get, Property Let,
Property Set
Rounding Abs, Int, Fix, Round, Sgn
Script Engine ScriptEngine, ScriptEngineBuildVersion,
ScriptEngineMajorVersion, ScriptEngineMinorVersion
Strings Asc, AscB, AscW, Chr, ChrB, ChrW
Filter, InStr, InStrB, InStrRev, Join
Len, LenB, Lcase, Ucase, Left, LeftB, Mid, MidB
Right, RightB, Replace, Space, Split, StrComp, String
StrReverse, Ltrim, Rtrim, Trim
Varients IsArray, IsDate, IsEmpty, IsNull, IsNumeric, VarType
IsObject, TypeName
Visual Basic for Applications Features Not In VBScript
Category Omitted Feature/Keyword
Array Handling Option Base
Declaring arr. with lower bound <> 0
Collection Add, Count, Item, Remove
Access to collections using ! character
(e.g., MyCollection!Foo)
Conditional #Const
Compilation #If...Then…#Else
Control Flow DoEvents, GoSub...Return, GoTo
On Error GoTo, On...GoSub, On...GoTo
Line numbers, Line labels
Conversion CVar, CVDate, Str, Val
Data Types All intrinsic data types except Variant
Type...End Type
Date/Time Date statement, Time statement
DDE LinkExecute, LinkPoke, LinkRequest, LinkSend
Debugging Debug.Print, End, Stop
Declaration Declare (for declaring DLLs), Optional, ParamArray, Static
Error Handling Erl, Error, Resume, Resume Next
File Input/Output All traditional Basic file I/O
Financial All financial functions
Object Manipulation TypeOf
Objects Clipboard, Collection
Operators Like
Options Deftype, Option Base,
Option Compare, Option Private Module
Select Case Expressions containing Is keyword or any comparison
operators
Expressions containing a range of values using the To
keyword.
Strings Fixed-length strings, LSet, Rset, Mid Statement, StrConv
Using Objects Collection access using !
VBScript Features not in Visual Basic for Applications
Category Feature/Keyword
Declarations Class
Miscellaneous Eval, Execute
Objects RegExp
Script Engine ScriptEngine, IdentificationScriptEngineBuildVersion
ScriptEngineMajorVersion, ScriptEngineMinorVersion
VBScript Language Reference
---------------------------
Language Element Description
Abs Function Returns the absolute value of a no.
Addition Operator (+) Sums two numbers.
And Operator Performs a logical conjunction on two expressions.
Array Function Returns a Variant containing an array.
Asc Function Returns the ANSI character code
corresponding to the first letter in a string.
Assignment Operator (=) Assigns a value to a variable or property.
Atn Function Returns the arctangent of a number.
Call Statement Transfers control to a Sub or Function procedure.
CBool Function Returns an expression that has been converted to a
Variant of subtype Boolean.
CByte Function Returns an expression that has been converted to a Variant of
subtype Byte.
CCur Function Returns an expression that has been converted to a Variant of
subtype Currency.
CDate Function Returns an expression that has been converted to a Variant of subtype Date.
CDbl Function Returns an expression that has been converted to a Variant of
subtype Double.
Chr Function Returns the character associated with the specified ANSI character code.
CInt Function Returns an expression that has been converted to a Variant of subtype Integer.
Class Object Provides access to the events of a created class.
Class Statement Declares the name of a class.
Clear Method Clears all property settings of the Err object.
CLng Function Returns an expression that has been converted to a Variant of
subtype Long.
Color Constants List of color constants.
Comparison Constants List of constants used in comparison operations.
Concatenation Operator (&) Forces string concatenation of two expressions.
Const Statement Declares constants for use in place of literal values.
Cos Function Returns the cosine of an angle.
CreateObject Function Creates and returns a reference to an Automation object.
CSng Function Returns an expression that has been converted to a Variant of subtype Single.
CStr Function Returns an expression that has been converted to a Variant of subtype String.
Date and Time Constants List of constants defining days of week and other constants used in Date and Time operations.
Date Format Constants List of constants used to format dates and times.
Date Function Returns the current system date.
DateAdd Function Returns a date to which a specified time interval has been added.
DateDiff Function Returns the number of intervals between two dates.
DatePart Function Returns the specified part of a given date.
DateSerial Function Returns a Variant of subtype Date for a
specified year, month, and day.
DateValue Function Returns a Variant of subtype Date.
Day Function Returns a whole number between 1 and 31, inclusive, representing the day of the month.
Description Property Returns or sets a descriptive string associated with an error.
Dictionary Object Object that stores data key, item pairs.
Dim Statement Declares variables and allocates storage space.
Division Operator (/) Divides two numbers and returns a floating-point result.
Do...Loop Statement Repeats a block of statements while a
condition is True or until a condition becomes True.
Empty Indicates an uninitialized variable value.
Eqv Operator Performs a logical equivalence on two expressions.
Erase Statement Reinitializes the elements of fixed-size arrays and deallocates dynamic-array storage space.
Err Object Contains information about run-time errors.
Eval Function Evaluates an expression and returns the result.
Execute Method Executes a regular expression search against a specified
string.
Execute Statement Executes one or more specified statements.
ExecuteGlobal Statement Executes one or more specified statements in the global namespace of a script.
Exit Statement Exits a block of Do...Loop, For...Next, Function, or Sub code.
Exp Function Returns e (the base of natural logarithms) raised to a power.
Exponentiation Operator (^) Raises a number to the power of an exponent.
False Keyword that has a value equal to zero.
FileSystemObject Object Provides access to a computer's file system.
Filter Function Returns a zero-based array containing a subset of a string array based on a specified filter criteria.
FirstIndex Property Returns the position in a search string where a match
occurs.
Fix Function Returns the integer portion of a number.
For...Next Statement Repeats a group of statements a specified number of times.
For Each...Next Statement Repeats a group of statements for each element in an array or collection.
FormatCurrency Function Returns an expression formatted as a currency value
using the currency symbol defined in the system control panel.
FormatDateTime Function Returns an expression formatted as a date or time.
FormatNumber Function Returns an expression formatted as a number.
FormatPercent Function Returns an expression formatted as a percentage
(multiplied by 100) with a trailing % character. Function
Statement Declares the name, arguments, and
code that form the body of a Function procedure.
GetLocale Function Returns the current locale ID value.
GetObject Function Returns a reference to an Automation object from a file.
GetRef Function Rn. a reference to a procedure that can be bound to an event.
Global Property Sets or returns a Boolean value.
Hex Function Returns a string representing the hexadecimal value of a no.
HelpContext Property Sets or returns a context ID for a topic in a Help File.
HelpFile Property Sets or returns a fully qualified path to a Help File
Hour Function Returns a whole number between 0 and 23, inclusive,
representing the hour of the day.
If...Then...Else Statement Conditionally executes a group of statements, depending on the value of an expression.
IgnoreCase Property Sets or returns a Boolean value that
indicates if a pattern search is case-sensitive or not.
Imp Operator Performs a logical implication on two expressions.
Initialize Event Occurs when an instance of the associated class is created.
InputBox Function Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.
InStr Function Returns the position of the first occurrence of one string within another.
InStrRev Function Returns the position of an occurrence of one string within another, from the end of string.
Int Function Returns the integer portion of a number.
Integer Division Operator (\) Divides two numbers and returns an integer result.
Is Operator Compares two object reference variables.
IsArray Function Returns a Boolean value indicating whether a variable is an
array.
IsDate Function Returns a Boolean value indicating whether an expression can be converted to a date.
IsEmpty Function Returns a Boolean value indicating whether a variable has been initialized.
IsNull Function Returns a Boolean value that indicates whether an expression
contains no valid data (Null).
IsNumeric Function Returns a Boolean value indicating whether an expression can
be evaluated as a number.
IsObject Function Returns a Boolean value indicating whether an expression
references a valid Automation object.
Join Function Returns a string created by joining a number of substrings contained in an array.
LBound Function Returns the smallest available subscript for the indicated dimension of an array.
LCase Function Returns a string that has been converted to lowercase.
Locale ID (LCID) Chart List of Locale ID's and their associated values.
Left Function Returns a specified number of characters from the left side of
a string.
Len Function Returns the number of characters in a string or the number of bytes required to store a variable.
Length Property Returns the length of a match found in a search string.
LoadPicture Function Returns a picture object. Available only on 32-bit platforms.
Log Function Returns the natural logarithm of a number.
LTrim Function Returns a copy of a string without leading spaces.
Match Object Provides access to the read-only properties of a regular
expression match.
Matches Collection Collection of regular expression Match objects.
Mid Function Returns a specified number of characters from a string.
Minute Function Returns a whole number between 0 and 59, inclusive,
representing the minute of the hour.
Miscellaneous Constants List of constants that don't fit into any other category.
Mod Operator Divides two numbers and returns only the remainder.
Month Function Returns a whole number between 1 and 12, inclusive,
representing the month of the year.
MonthName Function Returns a string indicating the specified month.
MsgBox Constants List of constants used with the MsgBox Function.
MsgBox Function Displays a message in a dialog box, waits for the user to click a button, and returns a value indicating which button the user clicked.
Multiplication Operator (*) Multiplies two numbers.
Negation Operator (-) Indicates the negative value of a numeric expression.
Not Operator Performs logical negation on an expression.
Now Function Returns the current date and time according to the setting of your computer's system date and time.
Nothing Disassociates an object variable from any actual object.
Null Indicates that a variable contains no valid data.
Number Property Returns or sets a numeric value specifying an error.
Oct Function Returns a string representing the octal value of a number.
On Error Statement Enables error-handling.
Operator Precedence List showing the order of precedence for various operators
used in VBScript.
Option Explicit Statement Forces explicit declaration of all variables in a script.
Or Operator Performs a logical disjunction on two expressions.
Pattern Property Sets or returns the regular expression pattern being searched for.
Private Statement Declares private variables and allocates storage space.
PropertyGet Statement Declares the name, arguments, and code that form the body
of a Property procedure that gets (returns) the value of a
property.
PropertyLet Statement Declares the name, arguments, and code that form the body of
a Property procedure that assigns the value of a property.
PropertySet Statement Declares the name, arguments, and code that form the body of
a Property procedure that sets a reference to an object.
Public Statement Declares public variables and allocates storage space.
Raise Method Generates a run-time error.
Randomize Statement Initializes the random-number generator.
ReDim Statement Declares dynamic-array variables, and allocates or reallocates storage space at procedure level.
RegExp Object Provides simple regular expression support.
Rem Statement Includes explanatory remarks in a program.
Replace Function Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Replace Method Replaces text found in a regular expression search.
RGB Function Returns a whole number representing an RGB color value.
Right Function Returns a specified number of characters from the right side of
a string.
Rnd Function Returns a random number.
Round Function Returns a number rounded to a specified number of decimal
places.
Run-time Errors List VBScript run-time errors.
RTrim Function Returns a copy of a string without trailing spaces.
ScriptEngine Function Returns a string representing the scripting language in use.
ScriptEngineBuildVersion Function Returns the build version number of the scripting
engine in use.
ScriptEngineMajorVersion Function Returns the major version number of the scripting
engine in use.
ScriptEngineMinorVersion Function Returns the minor version number of the scripting
engine in use.
Second Function Returns a whole number between 0 and 59, inclusive, representing
the second of the minute.
Select Case Statement Executes one of several groups of statements, depending on
the value of an expression.
Set Statement Assigns an object reference to a variable or property.
SetLocale Function Sets the global locale and returns the previous locale.
Sgn Function Returns an integer indicating the sign of a number.
Sin Function Returns the sine of an angle.
Source Property Returns or sets the name of the object or application that
originally generated the error.
Space Function Returns a string consisting of the specified number of spaces.
Split Function Returns a zero-based, one-dimensional array containing a
specified number of substrings.
Sqr Function Returns the square root of a number.
StrComp Function Returns a value indicating the result of a string comparison.
String Constants List of string constants.
String Function Returns a repeating character string of the length specified.
StrReverse Function Returns a string in which the character order of a specified
string is reversed.
Sub Statement Declares the name, arguments, and code that form the body
of a Sub procedure.
Subtraction Operator (-) Finds the difference between two numbers or indicates the
negative value of a numeric expression.
Syntax Errors List VBScript syntax errors.
Tan Function Returns the tangent of an angle.
Terminate Event Occurs when an instance of the associated class is
terminated.
Test Method Executes a regular expression search against a specified
string.
Time Function Returns a Variant of subtype Date indicating the current
system time.
Timer Function Returns the number of seconds that have elapsed since 12:00
AM (midnight).
TimeSerial Function Returns a Variant of subtype Date containing the
time for a specific hour, minute, and second.
TimeValue Function Returns a Variant of subtype Date containing the time.
Trim Function Returns a copy of a string without leading or trailing spaces.
Tristate Constants Use them anywhere in your code to represent the values
shown for each.
True Keyword that has a value equal to -1.
TypeName Function Returns a string that provides Variant subtype information
about a variable.
UBound Function Returns the largest available subscript for the indicated
dimension of an array.
UCase Function Returns a string that has been converted to uppercase.
Value Property Returns the value or text of a match found in a search string.
VarType Constants List of constants that define Variant subtypes.
VarType Function Returns a value indicating the subtype of a variable.
VBScript Constants Various categories of constants provided in VBScript.
Weekday Function Returns a whole number representing the day of the week.
WeekdayName Function Returns a string indicating the specified day of the week.
While...Wend Statement Executes a series of statements as long as a given condition
is True.
With Statement Executes a series of statements on a single object.
Xor Operator Performs a logical exclusion on two expressions.
Year Function Returns a whole number representing the year.
Property
Description Property Returns or sets a descriptive string associated with an error.
FirstIndex Property Returns the position in a search string where a match occurs.
Global Property Sets or returns a Boolean value.
HelpContext Property Sets or returns a context ID for a topic in a Help File.
HelpFile Property Sets or returns a fully qualified path to a Help File
IgnoreCase Property Sets or returns a Boolean value that indicates if a pattern
search is case-sensitive or not.
Length Property Returns the length of a match found in a search string.
Number Property Returns or sets a numeric value specifying an error.
Pattern Property Sets or returns the regular expression pattern being searched
for.
Source Property Returns or sets the name of the object or application that originally generated the error.
Value Property Returns the value or text of a match found in a search string.
Objects
Class Object Provides access to the events of a created class.
Dictionary Object Object that stores data key, item pairs.
Err Object Contains information about run-time errors.
FileSystemObject Object Provides access to a computer's file system.
Match Object Provides access to the read-only properties of a regular
expression match.
Matches Collection Collection of regular expression Match objects.
RegExp Object Provides simple regular expression support.
Methods
Clear Method Clears all property settings of the Err object.
Execute Method Executes a regular expression search against a specified string.
Raise Method Generates a run-time error.
Replace Method Replaces text found in a regular expression search.
Test Method Executes a regular expression search against a specified
string.
Events
------
Initialize Event Occurs when an instance of the associated class is created.
Terminate Event Occurs when an instance of the associated class is
terminated.
Errors
------
Run-time Errors List of VBScript run-time errors.
Syntax Errors List of VBScript syntax errors.
Regular Expression Syntax
-------------------------
A regular expression is a pattern of text that consists of ordinary characters (for example, letters a through z) and special characters, known as metacharacters. The pattern describes one or more strings to match when searching a body of text. The regular expression serves as a template for matching a character pattern to the string being searched.
Here are some examples of regular expression you might encounter:
JScript VBScript Matches
/^\[ \t]*$/ "^\[ \t]*$" Match a blank line.
/\d{2}-\d{5}/ "\d{2}-\d{5}" Validate an ID number consisting of 2 digits, a hyphen,
and another 5 digits.
/<(.*)>.*<\/\1>/ "<(.*)>.*<\/\1>" Match an HTML tag.
The following table contains the complete list of metacharacters and their behavior in the context of regular expressions:
Character Description
\ Marks the next character as either a special character, a literal, a backreference, or an octal escape. For example, 'n' matches the character "n". '\n' matches a newline character. The sequence '\\' matches "\" and "\(" matches "(".
^ Matches the position at the beginning of the input string. If the RegExp object's Multiline property is set, ^ also matches the position following '\n' or '\r'.
$ Matches the position at the end of the input string. If the RegExp object's Multiline property is set, $ also matches the position preceding '\n' or '\r'.
· Matches the preceding subexpression zero or more times. For example, zo* matches "z" and "zoo". * is equivalent to {0,}.
·
+ Matches the preceding subexpression one or more times. For example, 'zo+' matches "zo" and "zoo", but not "z". + is equivalent to {1,}.
? Matches the preceding subexpression zero or one time. For example, "do(es)?" matches the "do" in "do" or "does". ? is equivalent to {0,1}
{n} n is a nonnegative integer. Matches exactly n times. For example, 'o{2}' does not match the 'o' in "Bob," but matches the two o's in "food".
{n,} n is a nonnegative integer. Matches at least n times. For example, 'o{2,}' does not match the "o" in "Bob" and matches all the o's in "foooood". 'o{1,}' is equivalent to 'o+'. 'o{0,}' is equivalent to 'o*'.
{n,m} m and n are nonnegative integers, where n <= m. Matches at least n and at most m times. For example, "o{1,3}" matches the first three o's in "fooooood". 'o{0,1}' is equivalent to 'o?'. Note that you cannot put a space between the comma and the numbers.
? When this character immediately follows any of the other quantifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. A non-greedy pattern matches as little of the searched string as possible, whereas the default greedy pattern matches as much of the searched string as possible. For example, in the string "oooo", 'o+?' matches a single "o", while 'o+' matches all 'o's.
. Matches any single character except "\n". To match any character including the '\n', use a pattern such as '[.\n]'.
(pattern) Matches pattern and captures the match. The captured match can be retrieved from the resulting Matches collection, using the SubMatches collection in VBScript or the $0…$9 properties in JScript. To match parentheses characters ( ), use '\(' or '\)'.
(?:pattern) Matches pattern but does not capture the match, that is, it is a non-capturing match that is not stored for possible later use. This is useful for combining parts of a pattern with the "or" character (|). For example, 'industr(?:y|ies) is a more economical expression than 'industry|industries'.
(?=pattern) Positive lookahead matches the search string at any point where a string matching pattern begins. This is a non-capturing match, that is, the match is not captured for possible later use. For example 'Windows (?=95|98|NT|2000)' matches "Windows" in "Windows 2000" but not "Windows" in "Windows 3.1". Lookaheads do not consume characters, that is, after a match occurs, the search for the next match begins immediately following the last match, not after the characters that comprised the lookahead.
(?!pattern) Negative lookahead matches the search string at any point where a string not matching pattern begins. This is a non-capturing match, that is, the match is not captured for possible later use. For example 'Windows (?!95|98|NT|2000)' matches "Windows" in "Windows 3.1" but does not match "Windows" in "Windows 2000". Lookaheads do not consume characters, that is, after a match occurs, the search for the next match begins immediately following the last match, not after the characters that comprised the lookahead.
x|y Matches either x or y. For example, 'z|food' matches "z" or "food". '(z|f)ood' matches "zood" or "food".
[xyz] A character set. Matches any one of the enclosed characters. For example, '[abc]' matches the 'a' in "plain".
[^xyz] A negative character set. Matches any character not enclosed. For example, '[^abc]' matches the 'p' in "plain".
[a-z] A range of characters. Matches any character in the specified range. For example, '[a-z]' matches any lowercase alphabetic character in the range 'a' through 'z'.
[^a-z] A negative range characters. Matches any character not in the specified range. For example, '[^a-z]' matches any character not in the range 'a' through 'z'.
\b Matches a word boundary, that is, the position between a word and a space. For example, 'er\b' matches the 'er' in "never" but not the 'er' in "verb".
\B Matches a nonword boundary. 'er\B' matches the 'er' in "verb" but not the 'er' in "never".
\cx Matches the control character indicated by x. For example, \cM matches a Control-M or carriage return character. The value of x must be in the range of A-Z or a-z. If not, c is assumed to be a literal 'c' character.
\d Matches a digit character. Equivalent to [0-9].
\D Matches a nondigit character. Equivalent to [^0-9].
\f Matches a form-feed character. Equivalent to \x0c and \cL.
\n Matches a newline character. Equivalent to \x0a and \cJ.
\r Matches a carriage return character. Equivalent to \x0d and \cM.
\s Matches any whitespace character including space, tab, form-feed, etc.
Equivalent to [ \f\n\r\t\v].
\S Matches any nonwhite space character. Equivalent to [^ \f\n\r\t\v].
\t Matches a tab character. Equivalent to \x09 and \cI.
\v Matches a vertical tab character. Equivalent to \x0b and \cK.
\w Matches any word character including underscore. Equivalent to '[A-Za-z0-9_]'.
\W Matches any nonword character. Equivalent to '[^A-Za-z0-9_]'.
\xn Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For example, '\x41' matches "A". '\x041' is equivalent to '\x04' & "1". Allows ASCII codes to be used in regular expressions.
\num Matches num, where num is a positive integer. A reference back to captured matches. For example, '(.)\1' matches two consecutive identical characters.
\n Identifies either an octal escape value or a backreference. If \n is preceded by at least n captured subexpressions, n is a backreference. Otherwise, n is an octal escape value if n is an octal digit (0-7).
\nm Identifies either an octal escape value or a backreference. If \nm is preceded by at least nm captured subexpressions, nm is a backreference. If \nm is preceded by at least n captures, n is a backreference followed by literal m. If neither of the preceding conditions exist, \nm matches octal escape value nm when n and m are octal digits (0-7).
\nml Matches octal escape value nml when n is an octal digit (0-3) and m and l are octal digits (0-7).
\un Matches n, where n is a Unicode character expressed as four hexadecimal digits. For example, \u00A9 matches the copyright symbol (©).
Build a Regular Expression
--------------------------
Regular expressions are constructed in the same way that arithmetic expressions are created. That is, small expressions are combined using a variety of metacharacters and operators to create larger expressions. You construct a regular expression by putting the various components of the expression pattern between a pair of delimiters. For JScript, the delimiters are a pair of forward slash (/) characters. For example:
/expression/ For VBScript, a pair of quotation marks ("") delimit regular expressions. For example:
"expression" In both of the examples shown above, the regular expression pattern (expression) is stored in the Pattern property of the RegExp object. The components of a regular expression can be individual characters, sets of characters, ranges of characters, choices between characters, or any combination of all of these components.
Order of Precedence
-------------------
Once you have constructed a regular expression, it is evaluated much like an arithmetic expression, that is, it is evaluated from left to right and follows an order of precedence.
The following table illustrates, from highest to lowest, the order of precedence of the various regular expression operators:
Operator(s) Description
\ Escape
(), (?:), (?=), [] Parentheses and Brackets
*, +, ?, {n}, {n,}, {n,m} Quantifiers
^, $, \anymetacharacter Anchors and Sequences
| Alternation
Non-Printable Characters
------------------------
There are a number of useful non-printing characters that must be used occasionally. The following table shows the escape sequences used to represent those non-printing characters:
Character Meaning
\cx Matches the control character indicated by x. For example, \cM matches a Control-M or carriage return character. The value of x must be in the range of A-Z or a-z. If not, c is assumed to be a literal 'c' character.
\f Matches a form-feed character. Equivalent to \x0c and \cL.
\n Matches a newline character. Equivalent to \x0a and \cJ.
\r Matches a carriage return character. Equivalent to \x0d and \cM.
\s Matches any whitespace character including space, tab, form-feed, etc.
Equivalent to [\f\n\r\t\v].
\S Matches any non-whitespace character. Equivalent to [^ \f\n\r\t\v].
\t Matches a tab character. Equivalent to \x09 and \cI.
\v Matches a vertical tab character. Equivalent to \x0b and \cK.