str_replace_all on "[" character

Hey everyone

I am fiddling around with the stringr package and want to extract two values from a string into separate columns. My idea was first to replace the brackets by empty characters, then I have a comma-separated list that I can split. But I cannot declare the bracket as a character to be replaced.

tmp <- "[10, 20]"
str_replace_all(tmp, "[]", "")

This gives me an error that the brackets belong to the bracket expression. I tried a lot like "["[""]"]" and using \ as escape character but nothing worked.

I guess the solution is quite easy, but I cannot find it right now.

Thanks for helping!

Here's a way to replace the brackets with empty characters.

library(stringr)
tmp <- "[10, 20]"
str_replace_all(tmp, "\\[|\\]", "")
#> [1] "10, 20"

Created on 2022-12-21 with reprex v2.0.2.9000

thank you, good Sir.