Skip to content

Commit ee6386a

Browse files
committed
fun with pad_patent_id
1 parent b366e7b commit ee6386a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/search-pv.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ one_request <- function(method, query, base_url, arg_list, api_key, ...) {
140140
#'
141141
#' @export
142142
pad_patent_id <- function(patent_id) {
143-
n_zeros <- 8 - nchar(patent_id)
144-
patent_id <- paste0(strrep("0", n_zeros), patent_id)
145-
sub("(0+)([[:alpha:]]+)([[:digit:]]+)", "\\2\\1\\3", patent_id)
143+
padding <-strrep("0", 8 - nchar(patent_id))
144+
sub("^([[:alpha:]]*)([[:digit:]]+)", paste0("\\1", padding, "\\2"), patent_id)
146145
}
147146

147+
148148
#' @noRd
149149
request_apply <- function(result, method, query, base_url, arg_list, api_key, ...) {
150150
matched_records <- result$query_results[[1]]

0 commit comments

Comments
 (0)