regex multiple pattern with sigular replacement

I am trying to replace both "st." and "ste." with "st". Seems like the following should work but it does not:

require("stringr")
county <- c("st. landry", "ste. geneveve", "st. louis")
str_replace_all(county, c("st\\.", "ste\\."), "st")

Any assistance would be gretly be appreciated

Answers


You can use | to mean "or"

> str_replace_all(county, "st\\.|ste\\.", "st")
[1] "st landry"   "st geneveve" "st louis"   

Or in base R

> gsub("st\\.|ste\\.", "st", county)
[1] "st landry"   "st geneveve" "st louis"  

Need Your Help

Isssue with spring-beans.dtd file

spring hibernate spring-mvc

I am getting this error in my spring-hibernate.xml file

Website footer conflicting with <aside> content

html css html5 joomla2.5

I have a site set up in Joomla Here's the site using a custom grid responsive template. At the moment I have a pretty basic layout... Header - Section - Aside - Footer.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.