Back to Thingsboard

X509 Chain Regex Examples

ui-ngx/src/assets/help/en_US/device-profile/x509-chain-regex-examples.md

4.3.1.11.3 KB
Original Source

Examples of RegEx usage

The regular expression is required to extract device name from the X509 certificate's common name. The regular expression syntax is based on Java Pattern. You may also use this resource to test your expressions but make sure you select Java 8 flavor.

  • Pattern:<code>(.*).company.com</code>- matches any characters before the ".company.com".

CN sample:<code>DeviceA.company.com</code>

Result:<code>DeviceA</code>

  • Pattern: <code>(.*)@company.com</code>- matches any characters before the "@company.com".

CN sample:<code>[email protected]</code>

Result:<code>DeviceA</code>

CN sample:<code>[email protected]</code>

Pattern matches: <code>DeviceA</code>

  • Pattern: <code>\D+\.(.*)\.\[email protected]</code>- matches characters between not digits prefix followed by period and sequence of digits with "@company.com" ending.

CN sample:<code>[email protected]</code>

Pattern matches: <code>DeviceA</code>