Jump to content

quick stringinstr question


diveboy
 Share

Recommended Posts

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.

Link to comment
Share on other sites

  • Moderators

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)

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.

Link to comment
Share on other sites

  • Developers

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

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.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

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