Skip to content
Reference > Methods

strBeforeLast(text,toFind,origIfNotFound)

Definition

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

Description

Returns the portion of a string before the last occurence of a delimiter. If the delimiter is not found, then return either the original string or null depending on the 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 = strBeforeLast("What now"," ",true); // r1 == What
String r2 = strBeforeLast("what,now"," ",true); // r2 == what,now
Object r3 = strBeforeLast("what,now"," ",false); // r3 == null
Object r4 = strBeforeLast("what,now",null,false); // r4 == null
String r5 = strBeforeLast("what,now",null,true); // r5 == what,now
Object r6 = strBeforeLast(null," ",false); // r6 == null
String r7 = strBeforeLast("An example,of, multiple, delims",", ",true); // r7 == An example,of, multiple