in a flash of inspiration, i ALMOST solved the problem using the following code:
text.replaceText(".*", str2);
my inspiration actually came from reading about the method "replaceText".
the above code worked when i had only ONE paragraph in the google doc.
but when i had two paragraphs in the google doc, then the code gave a duplicate of the document, i.e., a 2nd exact copy of the two paragraphs just below the original two paragraphs (with correct capitalization of the sentences, including the beginning of the 2nd paragraph, but not the beginning of the 1st paragraph).
when i had 3 paragraphs, then i had 3 copies of these 3 paragraphs, such as shown below:
capitalize sentences. this is one example with ONE blank space after the period. here is another example with TWO blank spaces after the period. this is yet another example with MORE THAN THREE blank spaces.
capitalize sentences. this is one example with ONE blank space after the period. here is another example with TWO blank spaces after the period. this is yet another example with MORE THAN THREE blank spaces.
capitalize sentences. this is one example with ONE blank space after the period. here is another example with TWO blank spaces after the period. this is yet another example with MORE THAN THREE blank spaces.
then after running the script, i got 3 copies of these 3 paragraphs (with correct capitalization of the sentences, including the beginning of the 2nd and 3rd paragraphs), as shown below:
capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
Capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
Capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
Capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
Capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
Capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
Capitalize sentences. This is one example with ONE blank space after the period. Here is another example with TWO blank spaces after the period. This is yet another example with MORE THAN THREE blank spaces.
so there is still something wrong in the new code... which almost worked if i could get rid of the extra copies of the document.
returning to the original code
text.replaceText(str1, str2);
i suspect that there was something wrong with using the variable "str1" in the 1st argument of method "replaceText". it is hoped some experts could explain the error in my original code.