Was it helpful?

Question

How to check if a string is a subset of another string in R?

R ProgrammingServer Side ProgrammingProgramming

To check whether a string is a subset of another string we can use grepl function.

Example

> Company <- "TutorialsPoint"
> Job <- "Tutor"
> grepl(Job, Company, fixed = TRUE)
[1] TRUE

Here we are getting TRUE because Tutor is a subset of TutorialsPoint.

> grepl(Company, Job, fixed = TRUE)
[1] FALSE

Here we are getting FALSE because TutorialsPoint is not a subset of Tutor.

raja
Published on 06-Jul-2020 17:57:32
Advertisements
Was it helpful?
Not affiliated with Tutorialspoint
scroll top