I have multiple replace methods (I mean around 200 replace commands all nested in for loops). But some replace methods don't work at all. I am looping through the file using a For loop:
for(i=0; i<file.length; i++) {
but some replace methods are being ignored. Is there a reason why some methods are being ignored and some aren't?
EDIT1: I'm trying to replace multiple strings in a file.
file[i].replace(str1, str2)
file[i].replace(str3, str4)
file[i].replace(str5, str6)
file[i].replace(str7, str8)
file[i].replace(str9, str10)
...
and so on...
Here's the code:
Click here!
As written, none of the replace
statements are doing anything (assuming file
is a String[]
) because String
s are immutable and replace
returns a new String
without modifying the original. You'd need to write:
file[i] = file[i].replace(str1, str2);
精彩评论