Export (0) Print
Expand All

Make a String Field Match a Pattern

You can use the MATCH element to force values in a field of String type to follow a pattern that you specify. If you define multiple MATCH elements, the value will be valid if it matches any of the patterns that you specify for the field. If at least one element succeeds, the field has a valid value.

Note Note

To add a rule to a FIELD definition, use the witadmin command-line tool to import and export the definition for the work item type. See Customizing and Managing Work Item Types [witadmin].

You use the MATCH element to enforce basic pattern matching by defining a pattern that values in String type fields must match.

<MATCH pattern="patternValue" for="userGroupName" not="userGroupName" />

You can specify to which users the MATCH rule applies. If you do not define any optional attributes, all valid users and groups in Team Foundation Server must specify a value that matches the pattern.

Attribute

Description

pattern

Required. Enforces basic pattern matching for strings only. Valid values for the patternValue are "A", "N", and "X", which denote the following types of characters:

  • "A" represents an alphabetical character.

  • "N" represents a numeric character.

  • "X" represents any alphanumeric character.

All other values are taken as literals. Minimum length: 1; maximum length: 255.

Pattern value: ^[^\\]*$

Pattern value example: xxxxx.nn.nn

for

Optional. Specifies the name of a user or group in Team Foundation to whom the rule applies. Valid names consist of a string of text that contains between 1 and 255 characters.

Pattern value: ^[^\\]+\\[^\\]+$

Pattern value example: Domain\UserID

not

Optional. Specifies the name of a user or group in Team Foundation to whom the rule does not apply. Valid names consist of a string of text that contains between 1 and 255 characters.

Pattern value: ^[^\\]+\\[^\\]+$

Pattern value example: Domain\UserID

Back to top

The following examples illustrate successful and unsuccessful pattern matches for a variety of field uses.

Pattern: ANN.NN.NN

Validates

R01.03.04 or V05.08.99

Fails validation

1.3.4 or V5.8.99 or v1.3

Pattern: XXX-XXX

Validates

001-abc or a00-b02

Fails validation

1-abc or 001.abc

Pattern: PN

Validates

P1 or P5 or P9

Fails validation

1 or P10

Match tags are case-insensitive. Therefore, "PN" matches both P1 and p1.

Back to top

Show:
© 2014 Microsoft