OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Counting the number of lines in Google Document

  • Thread starter Thread starter Anton Dementiev
  • Start date Start date
A

Anton Dementiev

Guest
Problem:

I'd like to be able to count the number of lines in a Google Document. For example, the script must return 6 for the following text.

enter image description here

There doesn't seem to be any reliable method of extracting '\n' or '\r' characters from the text though.

Code:
text.findText(/\r/g)  //OR
text.findText(/\n/g)

The 2nd line of code is not supposed to work anyway, because according to GAS documentation, 'new line characters are automatically converted to /r'

<p>Problem:</p>

<p>I'd like to be able to count the number of lines in a Google Document. For example, the script must return 6 for the following text. </p>

<p><a href="https://i.sstatic.net/zgg2m.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zgg2m.png" alt="enter image description here"></a></p>

<p>There doesn't seem to be any reliable method of extracting '\n' or '\r' characters from the text though. </p>

<pre><code>text.findText(/\r/g) //OR
text.findText(/\n/g)
</code></pre>

<p>The 2nd line of code is not supposed to work anyway, because according to GAS documentation, 'new line characters are automatically converted to /r'</p>
 

Latest posts

Top