OnCommand Insight Device Resolution: Part 2 of 2 - Regular Expressions

Notes from this - April 2018 - YouTube video:
OnCommand Insight Device Resolution 102 - Regular Expressions

Image: Zone regular expression: Type = Host: Source = Zone: Method = Regular Expression

‘Zone regular expression’ also shows:
- All regular expressions for this auto resolution rule
- Order of precedence for regular expressions
- Number of matches with each additional expression

A Note on Regular Expressions

- A regular expression, often called a pattern, is an expression used to specify a set of strings required for a particular purpose.
- Regular expressions can be very broad - such as using (.*) which grabs the entire alias string - or can be create to capture one specific alias string.

Basics

- The () (parentheses) indicate the characters that are being extracted for device name.
- The . (period) is a wildcard that matches any character.
- The * (asterisk) matches the preceding character, or preceding bracketed characters, 0 or more times:
--- Example: tre* will find tree, tread and trough.
- The + (plus) matches the previous character 1 or more times:
--- Example: tre+ will find tree and tread but not trough.
- The ? (question mark) matches the preceding character 0 or 1 time only:
--- Example: colou?r will find both color and colour.

Example #1

Zone name: S0422_myComputer1Name_HBA3
Regular expression: S[0-9]+_([a-zA-Z0-9]+)[_-]HBA[0-9]
Explanation:
- Match everything starting with “S”
- One or more numbers
- A “_”
- A set of characters or numbers
- A “_” or “-“
- “HBA”
- With a single number
- Return what was matched in the first parenthesis (this is the meaning of \1)

Example #2

Zone name: myComputerName123_HBA1_Symm1_FA1
Regular expression: ([a-zA-Z0-9]+)_.*
Explanation:
- Return a set of all characters and numbers that appear in the zone name before the “_”
- Match  “_”
- And ‘.*’ anything after

Example #3

Zone name: MyComputerName_HBA1_Symm1_FA1
Regular expression: (.*?)_.*
Explanation:
- This regular expression will simply find anything before the first “_”
- “.*” is greedy and could grab everything up to the last “_” but the “?” says stop at the first

Example #4

Zone names: Z1_APPLE43A_FCAW0_SYMM_FA4A, Z2_BANANA44B_LPFC0_SYMM_FA4A, Z3_PEAR45C_FCAW0_SYMM_FA13A
Regular expression: .*?_([a-zA-Z0-9]+)_.*
Explanation:
- .*? will grab everything up to the first “_”
- ([a-zA-Z0-9]+) will grab everything to the second “_”

Enter Regular Expression

\1” format indicates which set of parentheses we are extracting device name from.

Image: NetApp OCI Enter Regular Expression

Best Practice: Set Auto resolution schedule to ‘Every Day’ at midnight.

Comments