Notes
In Apex, the containsOnly()
method is used to return true if the current String contains characters only from the specified sequence of characters and not any other characters; otherwise, returns false.
Here's an example for true:
String s1 = 'abba';
Boolean b1 = s1.containsOnly('abcd');
System.debug(b1);
Output: true
String s2 = 'abba xyz';
Boolean b2 = s2.containsOnly('abcd');
System.debug(b2);
Output: false
Video
Video does not exists.