Skip to content

ProtoString containsString() Method

Seth Clydesdale edited this page Jun 4, 2015 · 1 revision

<< Back to Miscellaneous Methods

Examples

Checking the entire string to see if it contains "String"

'ProtoString'.containsString('String'); // returns true

Passing true as the second parameter performs a case-insensitive search.

'ProtoString'.containsString('string'); // returns false

'ProtoString'.containsString('string', true); // returns true

Passing "start" as the third parameter performs a search at the start of the string, whereas passing "end" searches the end of the string.

'ProtoString'.containsString('String', false, 'end'); // returns true

'ProtoString'.containsString('String', false, 'start'); // returns false

'ProtoString'.containsString('Proto', false, 'start'); // returns true

Description

The contains method searches a string for a certain substring. It returns true if a match is found, and false if no match is found. You can choose to search the entire string, or the beginning and end, as well as perform a sensitive or insensitive search.

Syntax

String.containsString(str, i, at);

Parameters

Parameter Description
str A string that defines the substring that you want to search.
i A boolean value that defines whether or not the search should be case-insensitive. Setting this parameter to true will perform a case-insensitive search. Defaults to case-sensitive if left undefined.
at A string that defines whether the search should be at the beginning or end of the string. Possible values are start and end. Defaults to searching the entire string if left undefined.
Clone this wiki locally