Today in the optimization of a function encountered InStr and substr function, did not contact before these two functions, but today inadvertently used, a check only found, really practical pair of brothers Ah.
First of all, the SUBSTR function, which returns a part of the string.
SUBSTR (String,start,length)
Where the string parameter is a must parameter, the content of the strings to intercept.
Start is a required argument, the starting position, a positive number, or a negative number, and a positive word represents starting at the specified position in the string; a negative number represents the beginning of the specified position at the end of the string; 0 represents the beginning of the first character in a string.
Length is not a required parameter, and a positive number represents a trailing character from the position where the start parameter is located, and a negative number represents the forward character from the specified position at the end of the string.
As an example:
substr ("Hello world!", 2, 1) returns the E
substr ("Hello world!", 2) returned is Ello world!
substr ("Hello world!", -2,1) returns D
substr ("Hello world!", -2,-1) returns the d!
The InStr (string1, string2, start_position,nth_appearance) function returns the position of the string to intercept in the source string.
String1 the source string to find in this string.
String2 the string to find in the string1.
Start_position represents the starting position.
Nth_appearance representative to find the first occurrence of the string2. This parameter is optional, and if omitted, the default is 1. If the system is negative, it will give an error.
As an example:
InStr ("Hello world!", "O") returned is 5
The InStr ("Hello world!", "O", and "8") returned the same. To explain, this sentence represents "O" from the first position of the string to query, the second "O" where it appears.
It's a very useful two function.
Java Trivia encountered in development