Jump to content

Recommended Posts

Posted (edited)

Howdy folks. I'm using StringinStr and would like to search from the right, instead of the left. Taken directly from the help file, "Use a negative occurance to search from the right side." Unfortunately it doesn't work, I still get results from the left hand side of the string. Just run my simple example and see.

StringInStr ( "string", "substring" [, casesense [, occurance]] )

$test = "3,2,1"
$num = 1;

$check = StringInStr($test,$num,0,-1);

msgbox(0, "test", "should be 1: "&$check);

It should be 1, not 5, if it searched from the right. A bug, or am I overlooking something?

Edited by ravenfyre
  • Developers
Posted

Hmm that's kinda odd.  Oh well I guess that would be the easy way out ^^.

<{POST_SNAPBACK}>

Its not really "the easy way out" but its the way all string functions work.

It would be more difficult to use other String commands when it would return the found position seen from the right, since they all use the position from the left.

Just an example:

Assume you want to find the last octet of an IP address:

$IP = "192.168.0.213"
$oct4 = StringTrimLeft($IP,StringInStr($IP,".",0,-1))
MsgBox(0,'ip',$oct4)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...