Jump to content

StringInStr ("testXa","x",0,-1) why = 5 not 1 ?


Recommended Posts

$html="Mary had a little l/amb"

$test=StringInStr($html,"/",0,-1)

why $test=20 and not 4 ?

occurrence:- [optional] Which occurrence of the substring to find in the string. Use a negative occurrence to search from the right side. The default value is 1 (finds first occurrence).

im so dumb , what have i get wrong now ^_^ (it is late, no excuse)

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

  • Moderators

$html="Mary had a little l/amb"

$test=StringInStr($html,"/",0,-1)

why $test=20 and not 4 ?

occurrence:- [optional] Which occurrence of the substring to find in the string. Use a negative occurrence to search from the right side. The default value is 1 (finds first occurrence).

im so dumb , what have i get wrong now ^_^ (it is late, no excuse)

The returned character position is always left to right.

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

$html="Mary had a little l/amb"

$test=StringInStr($html,"/",0,-1)

why $test=20 and not 4 ?

occurrence:- [optional] Which occurrence of the substring to find in the string. Use a negative occurrence to search from the right side. The default value is 1 (finds first occurrence).

im so dumb , what have i get wrong now ^_^ (it is late, no excuse)

I doesn't matter from which side you start to search a character - the result will always counted from the left side!

If you need it from right side just reverse the string:

#Include <string.au3>
$html="Mary had a little l/amb"
$test=StringInStr(_StringReverse($html),"/" ,0)
MsgBox(0,"test",$test)

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I doesn't matter from which side you start to search a character - the result will always counted from the left side!

If you need it from right side just reverse the string:

#Include <string.au3>
$html="Mary had a little l/amb"
$test=StringInStr(_StringReverse($html),"/" ,0)
MsgBox(0,"test",$test)

UEZ

I think that _StringReverse() will be slower than StringLen().
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...