Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354765 - JS: only first instance of substring is replaced using replaceStr
Summary: JS: only first instance of substring is replaced using replaceStr
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-15 15:18 EDT by Kathy Carroll CLA
Modified: 2017-02-23 14:18 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kathy Carroll CLA 2011-08-15 15:18:52 EDT
handler MyHandler type RUIhandler {onConstructionFunction = start, cssFile="css/Alpha.css", title="MyHandler"}
	function start()
		SysLib.WriteStdOut("Hello from JavaScript Batch");
		replaceTest();
	end
	
	function replaceTest()
		actualStr String = "abcdefabcdefabcdefab".replaceStr("abc", "xyz");
        expectedStr string = "xyzdefxyzdefxyzdefab";
		if (actualStr == expectedStr)
			syslib.writeStdout("works");
		else
			syslib.writeStdout("fails");
			syslib.writeStdout(actualStr);
			syslib.writeStdout(expectedStr);
		end
	end
end

Output is:
Hello from JavaScript Batch
fails
xyzdefabcdefabcdefab
xyzdefxyzdefxyzdefab
Comment 1 Scott Greer CLA 2011-09-07 22:51:06 EDT
Added correct impl. of replaceStr, verified provided testcase.
Comment 2 Kathy Carroll CLA 2011-09-08 11:15:14 EDT
Verified with 0.7.0v201109080902.
Comment 3 Lisa Lasher CLA 2011-10-11 16:12:53 EDT
Closing this defect.