String.substringBefore()
Signature
String substringBefore (String s1, String s2)
Description
Returns the substring of the first parameter string s1
that precedes the first occurence of the second parameter string s2
in the first parameter sting s1
or null if the first parameter string s1
does not contain the second parameter string s2.
Parameters
Name | Type | Description |
s1 | String | A String to test. |
s2 | String | A String to search for in String s1 . |
Returns
Type | Description |
String | The result String. |
Example
String result = String.substringBefore ("Hello world", "orl");
Result is:
result 'Hello w'