Sign in to follow this  
Followers 0
diveboy

quick stringinstr question

4 posts in this topic

CODE

$filename = "Dexter-s02-e01er-s01-e02yr.avi"

$dot = StringInStr($filename,".",-1)

$fileext = Stringright($filename,($dot-1))

I'm trying to get the ".avi" from the $filename. the StringInStr function is returning 27 which is correct from the left, but the -1 should have it going from the right, which should give 5 correct ?

thanks

Michael.

Share this post


Link to post
Share on other sites



CODE

$filename = "Dexter-s02-e01er-s01-e02yr.avi"

$dot = StringInStr($filename,".",-1)

$fileext = Stringright($filename,($dot-1))

I'm trying to get the ".avi" from the $filename. the StringInStr function is returning 27 which is correct from the left, but the -1 should have it going from the right, which should give 5 correct ?

thanks

Michael.

You have -1 in the case sensitivity parameter.
$dot = StringInStr($filename, ".", 0, -1)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

CODE

$filename = "Dexter-s02-e01er-s01-e02yr.avi"

$dot = StringInStr($filename,".",-1)

$fileext = Stringright($filename,($dot-1))

I'm trying to get the ".avi" from the $filename. the StringInStr function is returning 27 which is correct from the left, but the -1 should have it going from the right, which should give 5 correct ?

thanks

Michael.

Nope... -1 (when used in the correct parameter position) means "find the first occurrence from the right" but still will returns the character position counting from the left.

:)

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

crap.

why didn't I see that.

Thanks a million.

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  
Followers 0