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

 
Line 1: Line 1:
{{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.
+
{{mirc title|$pos Identifier}}'''$pos''' returns the case-insensitive position of the Nth substring within a text string. '''$poscs''' is the case-sensitive version.
 
== Synopsis ==
 
== Synopsis ==
<pre>$pos(text,substring [,N] )</pre>
+
 
 +
<pre>$pos(text,substring [,N] )
 +
$poscs(text,substring [,N] )</pre>
 +
 
 
== Parameters ==
 
== Parameters ==
{{ArgsList
+
* '''text''' - The string being searched
| %var/text | The string being searched
+
* '''substring''' - The string being searched for within text string
| 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, you can use N=0 to return the count of string's occurrences.
| 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 ==
 
== Switches ==
 
None
 
None
 +
 
== Examples ==
 
== Examples ==
 
<source lang="mIRC">
 
<source lang="mIRC">
Line 32: Line 33:
  
 
== See also ==
 
== See also ==
* {{mIRC|$poscs}}
 
 
* {{mIRC|$mid}}
 
* {{mIRC|$mid}}
 
* {{mIRC|$left}}
 
* {{mIRC|$left}}
 
* {{mIRC|$right}}
 
* {{mIRC|$right}}

Latest revision as of 09:10, 15 February 2018

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

Synopsis[edit]

$pos(text,substring [,N] )
$poscs(text,substring [,N] )

Parameters[edit]

  • 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, you can use N=0 to return the count of string's occurrences.

Switches[edit]

None

Examples[edit]

//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[edit]

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[edit]