tests/testthat/test-str_split_extract.R

test_that("str_split_extract() split up a string into pieces and extract the results using a specific index position", {
  expect_equal(
    str_split_extract(c("Oyo-Ibadan", "Lagos-Ikeja", "Kwara-Ilorin"), pattern = "-", 2),
    c("Ibadan", "Ikeja", "Ilorin")
  )
})

Try the forstringr package in your browser

Any scripts or data that you put into this service are public.

forstringr documentation built on Aug. 7, 2023, 5:08 p.m.