Applications Docs Script ReplaceText: how to match a line break?

In a Google Docs doc, the normal effect of pressing the return key is to create a new paragraph, rather than inserting a line break character in the paragraph.

But paragraphs of text can have line breaks in them (for example, when inserted from other sources). I verified this by uploading the document as html; the relevant paragraphs have br tags inside. Also, the start and end lines of lines with these breaks do not match regExp ^ and $ in the replaceText command.

I would like to know how to match these line breaks to regular expressions in replaceText. Obvious ideas don't work:

'\r' 
'\\r'
'\n'
'\\n'
'\\\\n'
'\\\\r'
'\\\\\\\\n'
"\\[\\\\n\\\\r\\]\\+"
'< br >'
'< BR >'

      

This is used for an extension that fixes line breaks in selected text. So far, it concatenates paragraphs, which is sufficient if there are no line breaks in the paragraphs themselves.

Thanks for any help!

Mark

+3


source to share





All Articles