regex = "(?x)(xxxx) (?<id>[0-9A-Za-z]{4}) (?<number>[0-9]{5})" notable = "xxxxcn0700814" regexpr(regex,notable,perl = TRUE)
Standard input is empty
[1] 1 attr(,"match.length") [1] 13 attr(,"useBytes") [1] TRUE attr(,"capture.start") id number [1,] 1 5 9 attr(,"capture.length") id number [1,] 4 4 5 attr(,"capture.names") [1] "" "id" "number"