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:
(.).company.com
- matches any characters before the ".company.com".
CN sample:DeviceA.company.com
Result:*DeviceA
Pattern:
(.)@company.com
- matches any characters before the "@company.com".
CN sample:DeviceA@company.com
Result:*DeviceA
Pattern:
prefix(.)suffix@company.com
- matches characters between "prefix" and "suffix@company.com".
CN sample:prefixDeviceAsuffix@company.com
Pattern matches:*DeviceA
Pattern:
\D+\.(.)\.\d+@company.com
- matches characters between not digits prefix followed by period and sequence of digits with "@company.com" ending.
CN sample:region.DeviceA.220423@company.com
Pattern matches:*DeviceA