I have a list of street addresses like this:
d <- tribble(
~x,
‘505 BLACKBERRY’,
‘135 BEARDSLEY ST’,
’15 HUNT CLUB DR’,
‘1223 STATE ROUTE 103’,
‘455 STATE RTE 43’,
‘206 COUNTY RD 4710′,
’17 E 250TH ST’,
‘158 BALLINGER AVE SE’,
‘150 BALLINGER AVE S’,
’18 BALLINGER AVE T’ ,
‘1272 ORANGE SUN TRL’,
‘291 S MORELAND BLVD’,
‘615 RUSSET WOOD LN’,
‘1165 MORROCCO CT’,
‘1321 S PKWY DR’,
‘250 COUNTY RD 25A S’,
’22 SANSTONE RIDGE WAY’,
‘55070 MENDOZA TRL’,
‘1609 HUNTSMERE AVE DOWN’,
‘243 MISTY WOODS CV S’,
‘2292 BAYBERRY CMNS’,
’16 KILDEER CRK’,
’40 BEDFORD XING’,
‘4 LEXINGTON SQ’,
‘113 SPARROWS CRST’,
‘1082 MATHOM LNDG’,
‘1050 WILLOW RIDGE LOOP’,
‘660 REDTOP LOOP’,
‘8 MOUNT ROYAL LOOP’,
‘805 SIERRA OVAL’,
‘3012 NANTUCKET ROW’,
‘6 WOODROW AVE’,
‘943 DARROW PARK DR’,
‘743 BELVEDERE TER’,
‘189 WINCHESTER RD’,
’19 WHITE OAK TRCE’,
‘890 BLACKJACK RD EXT’,
‘767 N EXCALIBUR DR’,
‘109 VININGS FOREST LN SE’,
‘508 E 141ST ST’,
’85 ROSE LN ST SW’
)
I want to extract just the street names from the street address. I have written the following (admittedly gnarly) regular expression to do this: https://regex101.com/r/UdK6pB/1
It is working how I want it to work, but the problem is that when I drop it into R,the matches are not extracting and I do not know why.
Here is what I have tried:
d$street_name_only <- str_extract(d$x, “/((?:(?<=[0-9] )).[[:digit:]]$)||((?:(?<=[0-9] )).(?:(?=b(?:AVE|ST|DR|RD|LN|TRL|BLVD|CT|PKWY|JCT|SQ|HWY|WAY|CV|CMNS|CRK|XING|CRST|LNDG|LOOP|OVAL|ROW|TER|TRCE|RTE))))||((?:(?<=[0-9] ))[[:alpha:]]+$)/gm”)
I have also tried
d$street_name_only <- str_extract_all(d$x, “/((?:(?<=[0-9] )).[[:digit:]]$)||((?:(?<=[0-9] )).(?:(?=b(?:AVE|ST|DR|RD|LN|TRL|BLVD|CT|PKWY|JCT|SQ|HWY|WAY|CV|CMNS|CRK|XING|CRST|LNDG|LOOP|OVAL|ROW|TER|TRCE|RTE))))||((?:(?<=[0-9] ))[[:alpha:]]+$)/gm”)
but this does not work either.
Please help– i am at a loss for what I am doing wrong.