From WikiChip
Difference between revisions of "mirc/identifiers/$left"
< mirc‎ | identifiers

m
m (Fixed example)
Line 1: Line 1:
 
{{mirc title|$left Identifier}}'''$left''' is a {{mIRC|string manipulation}} identifier used to return characters from the left side of a string.
 
{{mirc title|$left Identifier}}'''$left''' is a {{mIRC|string manipulation}} identifier used to return characters from the left side of a string.
 
  
 
== Synopsis ==
 
== Synopsis ==
Line 8: Line 7:
 
<span style="display: inline-block; width: 105px;">'''<string>'''</span>The string to manipulate
 
<span style="display: inline-block; width: 105px;">'''<string>'''</span>The string to manipulate
  
<span style="display: inline-block; width: 105px;">'''<length>'''</span>The length or number of characters to remove from the original string. <length> can be a positive or negative. It cannot be 0.
+
<span style="display: inline-block; width: 105px;">'''<length>'''</span>The length or number of characters to remove from the original string. <length> can be a positive or negative. Using 0 returns $null (0 characters).
 
 
  
 
If the length provided is positive, $left will return the <length> characters from the left of the string.
 
If the length provided is positive, $left will return the <length> characters from the left of the string.
Line 15: Line 13:
 
; abcd</syntaxhighlight>
 
; abcd</syntaxhighlight>
  
If the length provided is negative, $left will return the characters in the string minus <length> on the right.
+
If the length provided is negative, $left will return the string except the rightmost <length> characters.
  
<syntaxhighlight lang="mirc">$left(abcdefg, -3)
+
<syntaxhighlight lang="mirc">$left(abcdefg, -2)
 
; abcde</syntaxhighlight>
 
; abcde</syntaxhighlight>
  
Line 26: Line 24:
 
<syntaxhighlight lang="mirc">$left([AB]BotName, 4)
 
<syntaxhighlight lang="mirc">$left([AB]BotName, 4)
 
; [AB]</syntaxhighlight>
 
; [AB]</syntaxhighlight>
 
  
 
== See also ==
 
== See also ==
Line 32: Line 29:
 
* {{mIRC|$right}}
 
* {{mIRC|$right}}
 
* {{mIRC|$mid}}
 
* {{mIRC|$mid}}
{{mIRC identifier list}}
+
* {{mIRC|$pos}}
 
 
[[Category:mIRC identifiers|left]]
 

Revision as of 10:53, 22 September 2022

$left is a string manipulation identifier used to return characters from the left side of a string.

Synopsis

$left(<string>, <length>)

Parameters

<string>The string to manipulate

<length>The length or number of characters to remove from the original string. <length> can be a positive or negative. Using 0 returns $null (0 characters).

If the length provided is positive, $left will return the <length> characters from the left of the string.

$left(abcdefg, 4)
; abcd

If the length provided is negative, $left will return the string except the rightmost <length> characters.

$left(abcdefg, -2)
; abcde

More Examples

$left(appleseed, -4)
; apple
$left([AB]BotName, 4)
; [AB]

See also