r - Problems in a regular expression to extract names using stringr -
i cannot understand why regular expression not work extract info want. have unlisted vector looks this:
text <- c("senator, 1.4balbal", "rule 46.1, declares", "town, 24", "a town long name, 23", "this document,23)
i create regular expression extract name of "town", if town has long name 1 written in vector ("a town long name"). have tried extract name of town:
reg.town <- "[[:alpha:]](.+?)+,(.+?)\\d{2}" towns<- unlist(str_extract_all(example, reg.prov))
but extract around ",".
thanks in advance,
it looks town name starts capital letter ([[:upper:]]
), ends comma (or continues end of text if there no comma) ([^,]+
) , should @ start of input text (^
). corresponding regex in case be:
^[[:upper:]][^,]+
Comments
Post a Comment