Determines whether each of the specified substrings appears exactly once in the given string.
The string to search within.
One or more substrings to check for single occurrence in str.
str
true if every substring appears exactly once in str, otherwise false.
true
false
ContainsSubstringOnlyOnce("hello world", "hello"); // trueContainsSubstringOnlyOnce("hello hello world", "hello"); // falseContainsSubstringOnlyOnce("hello world", "hello", "world"); // trueContainsSubstringOnlyOnce("hello world", "hello", "foo"); // false Copy
ContainsSubstringOnlyOnce("hello world", "hello"); // trueContainsSubstringOnlyOnce("hello hello world", "hello"); // falseContainsSubstringOnlyOnce("hello world", "hello", "world"); // trueContainsSubstringOnlyOnce("hello world", "hello", "foo"); // false
4.0.0
2021-12-14
Determines whether each of the specified substrings appears exactly once in the given string.