Use Regular Expression Examples





All characters after the leading "S".

We encountered barcodes with an extraneous "S" on cartons shipped by HP. This pattern says: “If a value starts with S, it’s a serial number, and the actual serial number is every character after the leading “S”. This is probably too broad for general use because you have other assets with serial numbers that legitimately begin with “S” and you don’t want the “S” stripped in those cases. To get around this, we’ve given HP assets their own form that will be used exclusively for HP assets.

Ideally, you could define a much tighter pattern like “HP serial numbers are always ”SCN + 8 characters, and strip off the leading S”. That would probably be specific enough so that HP assets wouldn’t need their own form. That pattern would be S(?<value>CN.{8})

Simpler as a prefix!

This is an example of a pattern that is simple enough to be implemented as a prefix instead of a pattern, but it's shown here because it's a simple example of a pattern.

Sample values:

  • SCNC819R159
  • SCNC819R10R
  • SCNC819R155

All characters that follow “1U”

This is an IBM pattern that is much more specific than the HP pattern. It says: “If a value starts with ”1S, then is followed by 1 or more characters, then “1U” followed by zero or more characters, it’s a serial number, and the actual serial number is every character after “1U”.

This pattern is specific enough that it’s very unlikely that you’ll run into any barcodes that share this pattern that aren’t IBM serial numbers. Thus we’re probably safe to not have a dedicated IBM form.

Sample values:

  • 1S679021UKA87DND
  • 1S679021UKA10RPG
  • 1S679021UKA70CTM

All characters except the last capital alphabet letter

We saw this pattern for some Ricoh products. “Every character except the last character” doesn’t allow us to discriminate between anything that’s scanned, so we tightened this up to express “If a value starts with Q followed by 10 digits followed by an uppercase alphabet character, it’s a serial number and the actual serial number is everything except the last character.”

Like the IBM pattern, this pattern is probably specific enough that we’re unlikely to encounter any barcodes that fit the pattern that aren’t Ricoh serial numbers. So in the sample form, it shares the same form as the IBM pattern.

Sample values:

  • Q3389300726O
  • Q3389300729R
  • Q3389400331H

Return only SL followed by 7 digits



Stripping & concatenation

You can specify multiple values to concatenate by adding a numeric suffix to the "value", for example, if the following pattern was specified for the Asset Tag field:


... and you scanned the barcode AA11BB22AA000, AssetTrack would:

  1. Detect that the scanned value matched the pattern specified for the Asset Tag field and therefore placed the resulting value into the Asset Tag field regardless of which field is currently focused.
  2. Extract two substrings based on the regular expression.

The resulting value placed into the configured field would be 1122.


Value from the middle of a string

Using the specified pattern would take the value AAFoobarAA and strip it down to Foobar.



Long scan pattern with terminator

This pattern used for BDC Room field

Note this patter for three concepts:

  1. Specifies an elaborate pattern using alpha-numeric, numeric and dot characters Note: The backslash escapes the dot character

2.      Has a $ to terminate (limit) the last input characters (used for data policies)
Ex: 123.A12.B12 vs 123.A12.B12000000000

  1. Uses the | character to OR two patterns
    Ex. User can specify 123.A12.B12 or 1Z-123.45


Another OR pattern

Used for BDC Asset Tags.

This is used for the Data Policy to allow either/or as specified on each side of the | (pipe) character.

The .* is sued to allow any type or number of characters.


  • BE123456
  • BA123456
  • BZ12WE34RT



Return only the last 7 characters when the string is 1S + 7 digits + 7 characters

This pattern illustrates that characters or digits that are desired to be scanned in, must reside within the (?<value>)... parenthesis.  And characters or digits desired to be trimmed should be outside of the (?<value>).

As you have seen in other pattern examples if you intend to trim literal characters place them outside of the (?<value>).

Ex: AA(?<value>[A-Za-z]{7})

In this case the letters AA will be trimmed from the scan. 

For this pattern (1S[0-9]{7})(?<value>[A-Za-z]{7}) we want to trim the 2 literal values 1S and 7 digits which makes this more complicated than just the  literal AA above, and therefore it is required that this piece of the expression be wrapped in parenthesis. (1S[0-9]{7})

Sample values:

Barcode value

Value that will appear in the scanner








Only allows a five digit number between 24000 and 29999.



Have more questions? Submit a request


  • John E Mcconnell

    I'd like to get a rule that errors on a serial number when people say things like UNKNOWN or (wildcard)DUP

    Comment actions Permalink

Please sign in to leave a comment.