extractIdCard static method

String? extractIdCard(
  1. String? naturalPersonBlock
)

ID card number (RG) stored at [30, 45) of the natural-person block.

Returns null when absent or filled with zeroes. Leading zeroes used as padding are stripped; the issuing body that follows the number is not numeric and is not returned here — read it from the raw otherName when needed.

Implementation

static String? extractIdCard(String? naturalPersonBlock) {
  final field = _fieldOrNull(naturalPersonBlock, _idCardStart, _idCardEnd);
  if (field == null) return null;
  final trimmed = field.replaceFirst(RegExp(r'^0+'), '');
  return trimmed.isEmpty ? null : trimmed;
}