Sign in to follow this  
Followers 0
lte5000

StringReplace unexpected behavior

3 posts in this topic

#1 ·  Posted (edited)

Expected results:

$a = "abc"
$a = StringReplace($a, "a", "")
MsgBox(0, "contents of var $a", $a)
Result of StringReplace() is "abc". I expected "bc".

Bug? Intended behavior? I don't know.

Thanks in advance for checking it out.

Edit: added what I expected.

Edited by lte5000

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Expected results:

$a = "abc"
$a = StringReplace($a, "a", "")
MsgBox(0, "contents of var $a", $a)
Result of StringReplace() is "abc". I expected "bc".

Bug? Intended behavior? I don't know.

Thanks in advance for checking it out.

Edit: added what I expected.

You forgot to mention why you expect only the first character to be replaced... :P

The StringReplace() starts replacing at position 1 with the lenght of the replace string ..which is zero so nothing will happen...

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

You forgot to mention why you expect only the first character to be replaced... :nuke:

I expected the first character (position 1) to be replaced with ""... because...well...just because. :)

But after thinking it through, your explanation makes more sense. :P

Thanks.

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