Skip to contents

Construct regex patterns

Usage

construct_regex(x)

Arguments

x

<chr> vector

Value

<chr> vector

Examples

construct_regex(search_descriptions()$hcpcs_code)
#> [1] "^[A-CEGHJ-MP-V0-9][0-9]{3}[AFMTU0-9]$"

construct_regex(search_hcpcs()$hcpcs_code)
#> [1] "^[A-CEGHJ-MP-V][0-9]{4}$"

# Incorrect:
construct_regex(search_adjustments()$adj_code)
#> [1] "^[A-DM-PWY1-9][AIOR0-9?][0-9?]{3}$"

# Should be:
"^[A-DM-PWY1-9][AIOR0-9]?[0-9]{0,3}?$"
#> [1] "^[A-DM-PWY1-9][AIOR0-9]?[0-9]{0,3}?$"

# Test adj codes
c("4", "CO", "P6", "100", "B19", "MA22", "MA124", "N766")
#> [1] "4"     "CO"    "P6"    "100"   "B19"   "MA22"  "MA124" "N766"