Reference: Regular Expressions

A regular expression is a formula composed of characters and operators that represent a specific pattern. This formula is used to locate text strings that match this pattern.

A simple example is searching your computer for a list of all the files that have the .txt extension. To do this, you use the substitution formula *.txt where * represents any alphanumeric characters A-Z or 0-9. Similarly, regular expressions allow you to create a formula that represents the text pattern to search for.

Regular expressions can be simple or very complex. For example, you can write expressions to search for any of the following:

  • Specific sequence of characters
  • Specific format such as (999)999-9999 to find phone numbers
  • Special characters such as spaces or tabs
  • Repeated words (or any text string)
  • One text string always followed by another text string

By using operators in your expression, you can find text that matches a pattern or text that does NOT match the pattern.

Sample Regular Expressions

Regular expressions can be used in several commands. There are samples for these commands that you can copy-and-paste, and then edit as needed.

  • Samples for the Import Format Editor command

Samples for the Advanced Select command

Selection criteria

(for object character strings such as names, point IDs, and feature codes)

Expression

(not case-sensitive)

Example

Select objects with a specific character in any position.

Enter a, where "a" is the character used in the search.

(Equivalent to *a* wildcard search.)

a will select apple, cat, and era.

Select objects with a specific character in the first position.

Enter ^a, where "a" is the character used in the search.

(Equivalent to a* wildcard search.)

^1 will select 1, 15, and 129F.

Select objects with a specific character in the second position.

Enter ^.a, where "a" is the character used in the search.

^.b will select aba, 1b2, and ab2

Select objects with a specific character in the third (or more) position.

Enter ^..a, where "a" is the character used in the search.

(Additional periods can be added to specify further positions in the string.)

^..n will select control and b2new

Select objects with a specific character in the last position.

Enter a$, where "a" is the character used in the search.

(Equivalent to *a wildcard search.)

s$ will select 205 s and cas

Select objects starting and ending with specific characters

Enter ^a.*b$, where "a" and "b" are the characters used in the search.

^p.*s$ will select pipes and points.

Select objects with one specific name (or part of a name) or another.

Enter ab|cd, where "ab" and "cd" are the names used in the search.

bush|shrub will select all objects (feature codes, for example) with bush or shrub as all or part of their names.

Select objects numerically or alphabetically ranging from one number or letter to another

Enter ^[a-d], where "a" and "d" are the characters that define the range used in the search.

^[2-5] will select 2, 3, and 5.

Select objects that include a decimal point or comma.

Enter \. or \,.

\. will select 1.0 and 0.025

Select objects that start with either of two specific characters

Enter ^[ab], where "a" and "b" are the character used in the search.

^[89] will select 8, 82, and 919

Select objects numerically or alphabetically ranging from one number or letter to more than one choice of number or letter repeated a specified number of times.

Enter [a-d]{x}, where "a" and "d" are the characters that define the range used in the search and “x” is the multiplier.

[1-9]{4} will select 1111, 3333, and 9999.

More information

For more short examples, see:

http://www.regular-expressions.info/reference.html.

Syntax details are located at:

http://en.wikipedia.org/wiki/Regular_expression

For a quick tutorial on regular expressions, visit:

https://www.codeproject.com/Articles/9099/The-30-Minute-Regex-Tutorial

Related topics

Definition Options

Description and Search Type Options

General Properties Options

Fields Options

Import Data in a Custom Format