Mid: Difference between revisions
Jump to navigation
Jump to search
Created page with "MID(''string'', ''start''[, ''length'']) '''Description''' MID returns a string containing characters from the middle of a string. The required parameter, ''string'', is any..." |
|||
(8 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.'' | |||
Mid(''string'', ''start''[, ''length'']) | |||
'''Description''' | '''Description''' | ||
Mid returns a string containing characters from the middle of a string. The required parameter, ''string'', is any valid string expression. The required parameter, ''start'', is any valid numeric expression. If ''start'' is greater than the length of ''string'', a zero-length string is returned (""). The optional parameter, ''length'', is any valid numeric expression and it specifies the number of characters to return. If ''length'' is not used, or exceeds the number of remaining characters in ''string'', all characters from ''start'' to the end of ''string'' are returned. | |||
== Example (Basic) == | |||
<pre> | <pre> | ||
Rem Mid Example | |||
' | 'Mid returns substring from string middle | ||
Dim Eric, Mister | |||
Eric = "Cartman" | Eric = "Cartman" | ||
Print "From Cartman:", Mid(Eric, 2, 3) | |||
Mister = "Hankey" | Mister = "Hankey" | ||
Print "From Hankey:", Mid(Mister, 4) | |||
</pre> | </pre> | ||
== Output == | |||
<pre> | <pre> | ||
Line 24: | Line 26: | ||
</pre> | </pre> | ||
== Related Items == | |||
[[left|Left]], [[right|Right]] | |||
[[Category:Language Reference]] | |||
[[Category:Strings]] | |||
[[ | [[Category:BASIC Functions]] |
Latest revision as of 15:30, 25 March 2019
This function is for BASIC compatibility. It is not available in pure JavaScript projects.
Mid(string, start[, length])
Description
Mid returns a string containing characters from the middle of a string. The required parameter, string, is any valid string expression. The required parameter, start, is any valid numeric expression. If start is greater than the length of string, a zero-length string is returned (""). The optional parameter, length, is any valid numeric expression and it specifies the number of characters to return. If length is not used, or exceeds the number of remaining characters in string, all characters from start to the end of string are returned.
Example (Basic)
Rem Mid Example 'Mid returns substring from string middle Dim Eric, Mister Eric = "Cartman" Print "From Cartman:", Mid(Eric, 2, 3) Mister = "Hankey" Print "From Hankey:", Mid(Mister, 4)
Output
From Cartman: art From Hankey: key