Regex for rectangle brackets in R

前端 未结 3 360
滥情空心
滥情空心 2021-01-18 13:04

Conventionally in R one can use metacharacters in a regex with two slashes, e.g. ( becomes \\(, but I find the same isn\'t true for square brackets.

mystring         


        
3条回答
  •  不思量自难忘°
    2021-01-18 13:45

    I would sidestep [ab] syntax and use (a|b). Besides working, it may also be more readable:

    gsub("(\\[|\\]|\\$)","",mystring)
    

提交回复
热议问题