'How to split string with "-" as delimiter

I tried to split string using "-" as delimiter. But why this doesn't work:

> stringr::str_split("158–170", "-")
[[1]]
[1] "158–170"

> strsplit("158–170", "-")
[[1]]
[1] "158–170"

I expect the output to be vector of two strings "158" and "170".



Sources

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

Source: Stack Overflow

Solution Source