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

(Create content for empty page)
 
Line 1: Line 1:
{{mirc title|$pos Identifier}}'''$pos''' returns the case-insensitive position of the Nth substring within a text string. See {{mirc|$poscs}} for the case-sensitive version.
+
{{mirc title|$pos Identifier}}'''$pos''' returns the case-insensitive position of the Nth substring within a text string. {{mirc|$poscs}} is the case-sensitive version.
 
== Synopsis ==
 
== Synopsis ==
 
<pre>$pos(text,substring [,N] )</pre>
 
<pre>$pos(text,substring [,N] )</pre>

Revision as of 18:20, 7 February 2018

$pos returns the case-insensitive position of the Nth substring within a text string. $poscs is the case-sensitive version.

Synopsis

$pos(text,substring [,N] )

Parameters

 %var/text The string being searched
substring The string being searched for within text string
N The Nth occurrence of substring being searched for. Default is 1 if parameter not used.

  • Note: N=0 returns count of string's occurrences. Returns $null if Nth substring not found.

Switches

None

Examples

//echo -a $pos(DEADBEEF,E)
returns: 2 (search is case-insensitive) (Default N=1 when 3rd parameter isn't used)
//echo -a $pos(DEADBEEF,e,2)
returns: 6
//echo -a $pos(DEADBEEF,e,0)
returns: 3 (count of letter 'e')
//echo -a $pos(deadbeef,db,1)
returns: 4
//echo -a $pos(DEADBEEF,x,0)
returns: $null (not found)
//var %a a $chr(32) b | echo -a The string has length $len(%a) and contains $pos(%a,$chr(32),0) spaces
//echo -a The path-less filename is $mid($mircexe, $calc(1+$pos($mircexe,\, $count($mircexe,\) ) ) )

Compatibility

Added: mIRC v4.52
Added on: 06 Jul 1996
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also