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

Tare Weights

Net Weights

Sign Fields

Fraction Fields

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 any additional weight from the basket itself.

Net WeightsSign FieldsFraction FieldsReturn to Top

Tare Weights

A 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.

Sign FieldsFraction FieldsReturn to Top

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)

Gross WeightsFraction FieldsReturn to Top

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)))

Gross WeightsTare WeightsReturn to Top

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))

Gross WeightsTare WeightsReturn to Top

Related Topics