This seems to meet your needs.
string <- " Hi buddy what's up Bro "
library(stringr)
str_replace(gsub("\\s+", " ", str_trim(string)), "B", "b")
# [1] "Hi buddy what's up bro"
More Related Contents:
- POSIX character class does not work in base R regex
- Match values in data frame with values in another data frame and replace former with a corresponding pattern from the other data frame
- Pattern matching using a wildcard
- finding close match from data frame 1 in data fame 2
- Find matching strings between two vectors in R
- Add a common Legend for combined ggplots
- Assign multiple new variables on LHS in a single line
- Where does R store packages?
- Trimming a huge (3.5 GB) csv file to read into R
- regular expressions in base R: ‘perl=TRUE’ vs. the default (PCRE vs. TRE)
- How to add a ggplot2 subtitle with different size and colour?
- Same function over multiple data frames in R
- How to conditionally highlight points in ggplot2 facet plots – mapping color to column
- Align multiple tables side by side
- How to make dodge in geom_bar agree with dodge in geom_errorbar, geom_point
- set only lower bound of a limit for ggplot
- Last Observation Carried Forward In a data frame? [duplicate]
- There is pmin and pmax each taking na.rm, why no psum?
- Extract file extension from file path
- How to change positions of x and y axis in ggplot2
- Add values to a reactive table in shiny
- Error with select function from dplyr
- R Plot Filled Longitude-Latitude Grid Cells on Map
- How to increase the size of points in legend of ggplot2? [duplicate]
- Creating a named list from two vectors (names, values)
- Are there global variables in R Shiny?
- Shifting a column down by one
- How to change stacking order in stacked bar chart in R?
- How can I count the number of NAs per group?
- R: How to split a data frame into training, validation, and test sets?