Is this a bug or not.
Code: Select all
lcTxt.s=",,,,,,,,"
lcTxt=ReplaceString(lcTxt,",,",",0,")
Debug lcTxt ; result ",0,,0,,0,,0," but expected ",0,0,0,0,0,0,0"
Code: Select all
lcTxt.s=",,,,,,,,"
lcTxt=ReplaceString(lcTxt,",,",",0,")
Debug lcTxt ; result ",0,,0,,0,,0," but expected ",0,0,0,0,0,0,0"
Code: Select all
lcTxt.s=",,,,,,,,"
lcTxt=ReplaceString(lcTxt,",,",",0,")
Debug lcTxt ; result ",0,,0,,0,,0," but expected ",0,0,0,0,0,0,0"
; == again
lcTxt.s=",,,,,,,,"
lcTxt=ReplaceString(lcTxt,",,",",0,", #PB_String_CaseSensitive, 1, 20)
Debug lcTxt ; result ",0,,0,,0,,0," but expected ",0,0,0,0,0,0,0"
; == again
lcTxt.s=",,,,,,,,"
While FindString(lcTxt, ",,")
lcTxt=ReplaceString(lcTxt,",,",",0,")
Wend
Debug lcTxt ; result ",0,,0,,0,,0," but expected ",0,0,0,0,0,0,0"
Code: Select all
,0,,0,,0,,0,
,0,,0,,0,,0,
,0,0,0,0,0,0,0,
No.swhite wrote:Is this a ReplaceString Bug?
He didn't call it a bug, he asked if it was a bug. Seems reasonable to me.Axolotl wrote: Thu Jul 31, 2025 3:03 pm BTW: Maybe it's not so good to use the word bug in subject lines. Actually it's an observed behavior, the decision bug or feature will be made by Fred at the end of all days anyway.
Yep! And I thank heaven for that! Otherwise, that function would be a whole mess, and could even produce an endless loop.Demivec wrote: Thu Jul 31, 2025 2:59 pm It does not search the replacements after they have each been made.
Code: Select all
lcTxt.s=",,,,,,,,"
lcTxt=ReplaceString(lcTxt,",",",0")
Debug lcTxt ; Result: ,0,0,0,0,0,0,0,0
Code: Select all
Define String.s = "'test',,345,'No',,,"
Define Regex.i = CreateRegularExpression(#PB_Any, ",(?=,)|,$")
Define NewString.s = ReplaceRegularExpression(Regex, String, ",0")
Debug String
Debug NewString