left, left include, left last match, left last match include
This function extracts a left part of the string either with a character position number or a matching pattern.
Indirect parameter passing is disabled
2
No. | Type | Description |
---|---|---|
1 input |
valid types | input string or value Attention: If 1st parameter is a parameter set, please refer to left [parameter set function] instead. Values of types other than string will be converted to strings first. |
2 input |
numeral | character position Positive: Keep number of characters counted from the left (0 = blank string, 1 = 1st character, etc.) |
Alt. 2 input |
string | matching pattern Function left ...: Return the left part of the string without the matching pattern. |
Type | Description |
---|---|
string | Extracted substring |
st[] = "The taste of the coffee!";
echo( left( st[], 0 ), " / ", left( st[], 1 ), " / ", left( st[], -2 ), " / ", left( st[], -1 ) );
echo( left( st[],99 ), " / ", left( st[],-99) );
echo;
echo( left( st[], ' taste' ), " / ", left include( st[], ' taste' ) );
echo( left( st[], ' ' ), " / ", left last match( st[], ' ' ) );
echo( left last match include( st[], 'e' ) ); // Strips exclamation mark only
echo;
echo( left( st[], 'c^ffee' ) ); // Softquoted string (no or single quotation marks) - matched
echo( left( st[], "c^ffee" ) ); // Quoted string (double quotation marks) - not matched
/ T / The taste of the coffe / The taste of the coffee
The taste of the coffee! /
The / The taste
The / The taste of the
The taste of the coffee
The taste of the
The taste of the coffee!
right [string function]
middle [string function]
outside [string function]
left [parameter set function]