Skip to content
Reference > Methods

strBefore(text,toFind,origIfNotFound)

Definition

String strBefore(String text, String toFind, Boolean origIfNotFound)

Description

Returns the portion of a string before the first occurence of a delimiter. If the delimiter is not found, then return either the original string or null depending on origIfNotFound param.

Parameter Definition

Name Type Description
text String The base string to get a substring from
toFind String the delimiter to find
origIfNotFound Boolean If the toFind parameter doesn't exist in the text: then return text if true or null if false

Examples

1
2
3
4
5
6
7
String r1 = strBefore("What now"," ",true); // r1 == What
String r2 = strBefore("what,now"," ",true); // r2 == what,now
Object r3 = strBefore("what,now"," ",false); // r3 == null
Object r4 = strBefore("what,now",null,false); // r4 == null
String r5 = strBefore("what,now",null,true); // r5 == what,now
Object r6 = strBefore(null," ",false); // r6 == null
String r7 = strBefore("An example,of, multiple, delims",", ",true); // r7 == An example,of