Jump to content
Sign in to follow this  
lte5000

StringReplace unexpected behavior

Recommended Posts

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

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

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  

×
×
  • Create New...