This makes no sense to me, can anybody explain this?

# plus-sign seems to be found in all kinds of strings

grepl("+", "1500") # TRUE

grepl("+", "a") # TRUE

grepl("+", "abc123") # TRUE

# With some reading from Regular Expressions as used in R, We find that regular expression might be followed by some

# reperation quantifier. For plus sing:

# + = The preceding item will be matched one or more times.

# So what do we have here as our pattern? It seems that we have empty string '' with + sing.

# With empty string, we find that

grepl("", "1500") # TRUE

grepl("", "a") # TRUE

grepl("", "abc123") # TRUE

# So with pattern '+', empty string will be matched, which returns true to any string.

# If we want to find string containing '+', we use

grepl("\\+", c("1500", "a", "abc123", "stringwithplus+")) # F F F T

/r/Rlanguage Thread