OuhscBbmc / StatisticalComputing

OUHSC's SCUG (Statistical Computing Users Group)
MIT License
8 stars 3 forks source link

grep() versus grepl() #12

Closed Maleeha closed 4 years ago

Maleeha commented 4 years ago

In reference to the example in issue #11:

regex <- "(^\D\D\D\D)|-\D\D\D\D|(^\D+)3"


- `grep` returns terms that contain matches:

grep(regex, pax, value=T) [1] "asdgf2" "asd3" "bcdfs4" "zsdfs5"
[5] "asdfs6" "podf-podf-podf-podf-podf"


- `grepl` returns whether the "terms with matches" are `TRUE` or `FALSE`

grepl(regex, pax) [1] TRUE TRUE TRUE TRUE TRUE TRUE

Thanks again for the review @wibeasley

wibeasley commented 4 years ago

correct.