[datatable-help] Regular Expression on Text
Nicolas Paris
niparisco at gmail.com
Sun Apr 2 13:14:44 CEST 2017
Hi,
This maiy help ?
> help <- function(string){paste0(sprintf("%02d", as.numeric(gsub("^(\\d+).*","\\1",string))),substr(paste0(gsub("^(\\d+)([A-z]+).*","\\2",string),"___"),1,4),sprintf("%03d", as.numeric(gsub(".*(\\d+)$","\\1",string))))}
> help("02AR22")
[1] "02AR__002"
But remember, this question in not intended for data.table.
Le 02 avril 2017 à 09:18, ankur écrivait :
> Hi,
>
> I need an urgent help on handling below issue format:
> Format: "00__000" (2 numeric, 3 alphabets, 3 numeric)
> Text: 2AR22
> Results: "02AR__220"
>
> Thanks in advance for your help.
>
> Ankur K
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Regular-Expression-on-Text-tp4730906.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
More information about the datatable-help
mailing list