Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 谷歌文档-删除段落结尾的多余空格字符_Regex_Google Apps Script_Google Docs - Fatal编程技术网

Regex 谷歌文档-删除段落结尾的多余空格字符

Regex 谷歌文档-删除段落结尾的多余空格字符,regex,google-apps-script,google-docs,Regex,Google Apps Script,Google Docs,我试图有一个气体,将删除多余的空格字符的段落结尾 如何实现这一目标 示例: This is sentence 1 in paragraph 1. This is sentence 2 in paragraph 1 This is paragraph 2 (more text...) paragraphs[i].replaceText(/\h\r/g,"\r"); 在“……第1段第2句”之后有一个空格字符。(即“…第1段第2句”。 我想通过使用代码来摆脱它 到目前为止我试过了: Th

我试图有一个气体,将删除多余的空格字符的段落结尾

如何实现这一目标

示例

This is sentence 1 in paragraph 1. This is sentence 2 in paragraph 1 
This is paragraph 2 (more text...)
    paragraphs[i].replaceText(/\h\r/g,"\r");
在“……第1段第2句”之后有一个空格字符。(即“…第1段第2句<代码>”。 我想通过使用代码来摆脱它

到目前为止我试过了

This is sentence 1 in paragraph 1. This is sentence 2 in paragraph 1 
This is paragraph 2 (more text...)
    paragraphs[i].replaceText(/\h\r/g,"\r");
其中,
段落[i]
是我正在检查的段落(在文档正文的所有段落中循环)

它会产生此错误

This is sentence 1 in paragraph 1. This is sentence 2 in paragraph 1 
This is paragraph 2 (more text...)
    paragraphs[i].replaceText(/\h\r/g,"\r");
异常:无效的正则表达式模式/\h\r/g

我承认我对正则表达式有非常基本的了解。

试试看

paragraphs[i].replaceText("\\s+$","");// double `\\` is intentional
  • \s
    s
  • $
    :字符串结尾