I initially emphasize that I do not know all the standards of your financial transaction information. Only by taking Sample Data that you have informed, maybe the solution below will provide satisfactory information for your problem.
#install.packages("stringr")
vetor <-
c(
"IMPARK00030305U",
"SP * MARILLA WALKER PA",
"CALG CO-OP GAS",
"E-TRANSFER CA***csN",
"NATIONAL OILWEL PAY",
"ONCE UPON A CHILD CALG",
"MCDONALD'S #919 _F",
"TFR-FR 5226417",
"OLD COUNTRY MAR",
"VALLEYVIEW HUSK",
"ENMAX HH#002",
"SAFEWAY #8918",
"TELUS MOBILITY PREAUTH",
"BEACON MARTINIZ _F",
"SHELL C01766",
"CHAPTERS 964 _F",
"CHASIN TAILS _F",
"AMAZON.CA UU#001"
)
stringr::str_extract(vetor, pattern = "[:alpha:]*\\s*[^[:digit:.]]\\s*[:alpha:]*\\s*[:alpha:]")
You could first handle transaction information using Regex. After the information you have processed is sufficient, incorporate it into your table. I think this approach would be the most interesting.
Return:
> stringr::str_extract(vetor, pattern = "[:alpha:]*\\s*[^[:digit:]*[:punct:]*]\\s*[:alpha:]+\\s*[:alpha:]*[:alpha:]+")
[1] "IMPARK" " MARILLA WALKER" "CALG CO" "TRANSFER CA"
[5] "NATIONAL OILWEL PAY" "ONCE UPON A" "MCDONALD" "TFR"
[9] "OLD COUNTRY MAR" "VALLEYVIEW HUSK" "ENMAX HH" "SAFEWAY"
[13] "TELUS MOBILITY PREAUTH" "BEACON MARTINIZ" "SHELL C" "CHAPTERS"
[17] "CHASIN TAILS" "AMAZON"
Note: Try to work better on the argument passed to the pattern in str_extract() function.
Best regards,
prdm0