Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Regex with R Script

Hi,

I have a table containing Postal code and the regex pattern this postal code should follow to be correct.

What I want is a new column saying if the Postal code is matching the Pattern provided in the same row or now. With a simple TRUE/FALSE statement.

Currently I have tested this script in "R Script":

 

 

isMatch <- function(x,y) {grepl(y, as.character(x), ignore.case=TRUE)}
return <- within(dataset,{Flag=isMatch(dataset$Zip, dataset$Pattern)})

 

 

But as you can see, none of the records are matching.

Any suggestion on how to do this would be very helpful. Don't have to be in R Script 🙂

I will have a full table of 200k Postal codes coming up soon.

Thanks!

4 Replies