Navigation:  Commands and Procedures >

Regular Expressions

Previous pageReturn to chapter overviewNext page

Many Visual Build actions support the use of regular expressions for matching and/or replacing text.  Visual Build actions utilize the Boost regex and Microsoft .NET regex engines, which use a syntax compatible with Perl regex.

 

Note: Bracket characters [ and ] and the percent sign character % within step fields have special meaning in Visual Build.

 

Tutorials/References/Tools

Regular Expression Tutorial
Regexlib.com
RegexBuddy
Mastering Regular Expressions
Regular Expressions Cookbook
Microsoft Regex Documentation

 

Overview

Description

Description

Expression

Matches

Literal Characters

Any non-special characters will match exactly what is typed

the dog

the dog

Special Characters

Meta-characters that have a special meaning in expressions: \ ^ $ . | ? * + [ ] ( )

Use \ to escape a special character and match it

\\abc\.

\abc.

Any Character

Matches any character (except newline depending on configuration)

.

any single character

Character Class

Matches only one of several characters, or matches any character not in the class if negated

[[aeiou]]

[[^y]]

\w

\d

\s

\W

\D

\S

any vowel character

any character except y

word character

digit

whitespace

non-word character

non-digit character

non-white space character

Anchors

Match a position before, after, or between characters

^

$

\A

\z

\b

\B

beginning of line

end of line

beginning of string/file

end of string/file

word boundary

not-word boundary

Repetition

Matches 0, 1, or more times

Jan(uary)?

a*

b+

x{1,3}

Jan or January

nothing, a, aa, aaa, etc.

b, bb, bbb, etc.

x, xx, or xxx

Alternation

Match a single expression of several possible expressions

cat|dog|bird

any of 'cat', 'dog', or 'bird'

Grouping

Group part of an expression together

()

(?:)

(?>)

capture to numbered expression

group without capture

atomic grouping

Lookaround

Match characters, but give up the match and only return the result.

 

(?=)

(?!)

(?<=)

(?<!)

positive lookahead

negative lookahead

positive lookbehind

negative lookbehind

Back references

Reuse part of an expression or reference for substitution

\1 or $1

first matching group