Check a string that MUST contain another string [duplicate]

Read the documentation: MDC String.indexOf 🙂

indexOf returns the index the match was found. This may be 0 (which means “found at the beginning of string”) and 0 is a falsy value.

indexOf will return -1 if the needle was not found (and -1 is a truthy value). Thus the logic on the test needs to be adjusted to work using these return codes. String found (at beginning or elsewhere): index >= 0 or index > -1 or index != -1; String not found: index < 0 or index == -1.

Happy coding.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)