Jump to content
Sign in to follow this  

StringinStr, search from right not working

Recommended Posts

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

Share this post

Link to post
Share on other sites

No, that is not a bug.

It's not necessary from which side you're searching for a string, the string position will be ever the same!.

("Success: Returns the position of the substring.")

Edited by Holger

Share this post

Link to post
Share on other sites

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


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 = ""
$oct4 = StringTrimLeft($IP,StringInStr($IP,".",0,-1))

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.

Share this post

Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...