PCRE 2+
(?x)
# fingerprint and grip records only have about 12 fields,
# so the match can't be too strict with the number of mandatory fields.
^
(?<FullRecordType>
(?<fieldRecortdType>[^:]*):
# 2
(?<fieldValidity>[^:]*):
# 3
(?<fieldKeyLength>[^:]*):
# 4
(?<fieldAlgo>[^:]*):
# 5 - field id
(?>[^:]*):
# 6
(?<fieldDate>[^:]*):
# 7
(?<fieldExpires>[^:]*):
# 8
(?<fieldSerialHash>[^:]*):
# 9 - owner trust
(?>[^:]*):
# 10 - IMPORTANT - USER ID !!!
(?<fieldUserID>[^:]*):
# 11 - sig class
(?>[^:]*):
# 12 - identity keys have no capability
(?<fieldCapabilities>[^:]*):
# 13 - issuer other info
# 14 - flag field
# 15 - serial number
(?>[^:]*):{3}
# 16 - hash algo
(?<fieldHashAlgo>[^:]*):
# 17 - curve name
(?<fieldCurveName>[^:]*):
# 18 - compliance
# 19 - udpated
# 20 - origin
# 21 - comment
(?>[:\d]){3,4}
# End MainRecordType.
)
# Short Record Type.
# (?<ShortRecordType>)*
Final: https://regex101.com/r/Ig8Xpc/1
Semi-uglyfied (line breaks):
(?x) (?<KeyRecordType>(?<fieldKeyType>pub|sub):(?<fieldKeyStatus>[^:]*):(?<fieldLength>[^:]*):(?<fieldPubKeyAlgo>[^:]*):(?<fieldKeyID>[^:]*):(?<fieldCreated>[^:]*):(?<fieldExpires>[^:]*):(?<fieldTrust>[^:]*):(?<fieldOwnerTrust>[^:]*):(?<fieldUserID>[^:]*):(?<fieldSigClass>[^:]*):(?<fieldCapability>[escaD?]+)\w*:(?:[^:]*:){4}(?<fieldCurveName>[^:]*):(?<fieldRest>[:\d]*)\n?) (?<FingerprintRecordType>^(?:fpr|fp2):(?:[^:]*:){8}(?<fingerprint>\w*):(?:[^:]*:)*?\n?) (?<GripRecordType>^grp:(?:[^:]*:){8}(?<grip>\w*):(?:[^:]*:)*?\n?) (?<IdentityRecordType>uid:(?=u)(?<fieldIdentityStatus>[^:]):(?:[^:]*):{3}(?<fieldIdentityCreated>[^:]*)(?:[^:]*):{2}(?<fieldIdentityID>[^:]*)(?:[^:]*):{2}(?<fieldIdentityComment>[^:]*):(?<fieldIdentityRest>[:\d]*)\n?)*