As a solution I created a self-written identifier for you: $posmir (position mirror) ‒ returns the position of found characters in the string in reverse order.

Syntax: $posmir(text,string,N) ‒ If it is convenient for you to specify negative values (N = -1) in your script, then it will work in the same way (analogically) as with numbers greater than zero.

Example1: $posmir(abccba abca cbcba,bc,0) ‒ Returns: 3
Example2: $posmir(abccba abca cbcba,bc,1) ‒ Returns: 14
Example3: $posmir(abccba abca cbcba,bc,3) ‒ Returns: 2
Example4: $posmir(abccbaabcacbcba,$chr(32),0) ‒ Returns: 2
Example5: $posmir(abccba abcacbcba,$chr(32),1) ‒ Returns: 12

Code
alias posmir {
  if (($1 != $null) && ($2 != $null) && ($3 != $null)) {
    if ($3 == 0) return $pos($1,$2,$3)
    var %pm1 $1 | var %pm2 $2 | var %pm3 $remove($3,-)
    var %pm_a $pos(%pm1,%pm2,0)
    var %pm_c $calc(%pm_a +1 - %pm3)
    var %pm_p $pos(%pm1,%pm2,%pm_c)
    if (%pm3 <= %pm_a) return %pm_p | else return 0
  }
  echo -sc info * insufficient parameters ‒ $+(correct syntax:,$color(notice).dd) $eval($posmir(text,string,N),0) | halt
}

Testing commands:
Code
//echo -a $posmir(abccba abca cbcba,bc,0)
//echo -a $posmir(abccba abca cbcba,bc,1)
//echo -a $posmir(abccba abca cbcba,bc,3)
//echo -a $posmir(abccba abca cbcba,$chr(32),0)
//echo -a $posmir(abccba abca cbcba,$chr(32),1)


This is probably what you would like to see. Though I also support your idea for realization negative values in built-in identifier "$pos".


Last edited by Epic; 28/05/21 04:33 PM. Reason: changes in code after comment from maroon

🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples