Regular Expression Examples

BarTender supports regular expressions (also known as RegEx or RegExp) for use with scales. Below, you will find brief explanations and examples of proper syntax for using these measurement tools with your scale.

Gross Weights

The gross weight of an item is the actual scale result of weighing it, including any container. For instance, if you were to weigh a basket of berries from the grocery store, the result would be a gross weight, namely, the weight of the berries themselves plus additional weight from the basket itself.

Tare Weights

The tare weight is the weight of a given unladen container. For instance, the trailer of a semi-truck has a tare weight which is used to calculate the weight of its cargo by subtracting the tare weight from the gross weight result on the scale.

Net Weights

When weighing a substance, the net weight represents the total weight of the substance itself, minus the weight of any container. The example below is an example using net weights, gross weights, and tare weights.

(?:U\d\d(?:(?<NetStable>1)|\d)W\d+\x20*N\x20*(?:(?<NetSign>-)|\x2B)?(?<NetWeight>(?:\x2E|,)?\d+(?:(?:\x2E|,)\d+)?)\x20*(?<Units>(?<Net_kg>kg)|(?<Net_g>g)|(?<Net_lb>lb)))\x20*(?:\x0D\x0A)T\x20*(?:(?<TareSign>-)|\x2B)?(?<TareWeight>(?:\x2E|,)?\d+(?:(?:\x2E|,)\d+)?)\x20*(?<Units>(?<Tare_kg>kg)|(?<Tare_g>g)|(?<Tare_lb>lb))\x20*(?:\x0D\x0A)

Sign Fields

Sign functions take a given weight value and multiply it by -1. The example below uses a sign field to represent the result "000000N -0.05kg:

(?:\d{6}N\x20*(?:(?<Sign>-)|\x2B)?(?<Weight>(?:\x2E|,)?\d+(?:(?:\x2E|,)\d+)?) (?<Units>(?<kg>kg)|(?<g>g)|(?<lb>lb)))

Fraction Fields

Some scales represent weights using fractions, such as 1 3/4 lbs. The example below represents a net weight of "3 7/8 oz."

(?<NetWeight>(?:(?<NetWholeValue>\d+)\x20(?<NetNumerator>\d+)/(?<NetDenominator>\d+)))\x20+(?<Units>(?<Net_g>g)|(?<Net_oz>oz))

Related Topics