Jump to content

StringReplace unexpected behavior


Recommended Posts

  • Developers

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

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

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.

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