'remove words based on first letter using stringr

I want to remove all words that start with "a" in a string.

Input:

string <- "This is a sentence about nothing."

My attempt:

stringr::str_remove_all(string,"a*\\b")

output I got:

[1] "This is  sentence about nothing."

output I want:

[1] "This is sentence nothing."

I am not sure how to detect based on one letter but perform action(e.g., remove, replace) on the whole word. Any input is appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source