简体   繁体   English

如何在R中的特定单词后删除空格

[英]How to remove a space after a specific word in R

For example, if the word is happy , then: 例如,如果单词happy ,则:

Input: "The Bunny is happy to be alive, the Rabbit is happy too" 输入: "The Bunny is happy to be alive, the Rabbit is happy too"

Output: "The Bunny is happyto be alive, the Rabbit is happytoo" 输出: "The Bunny is happyto be alive, the Rabbit is happytoo"

Thank you 谢谢

Use following regex 使用以下正则表达式

(?<=happy)\\s

in the comment of your question, you are replacing word + whitesace on word . 在问题评论中,您要在word上替换word + whitesace But in approach placed above, you are removoing only whitespace. 但是在上面放置的方法中,您仅去除了空格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM