Can anyone explain why the veritcal bar symbol ("|") is matching with every string pattern. What is the solution for the issue.
> grepl("|", "DateNumber")
[1] TRUE
> grepl("|", "Dat")
[1] TRUE
> grepl("|", "t")
[1] TRUE
> grepl("|", "")
[1] TRUE
> grep("|", "Date Number")
[1] 1
> grep("|", "DateNumber")
[1] 1
> grep("|", "Date")
[1] 1
Thanks in Advance.
grepl()
uses "Regular Expressions" so "|" is being interpreted as the OR
logical operator, not the "pipe" symbol, if you want to match it literally, you have to escape it with \\
grepl("\\|", "DateNumber")
[1] FALSE
1 Like
Thank you so much @andresrcs
system
Closed
January 26, 2023, 4:20pm
4
This topic was automatically closed 42 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.