【发布时间】:2018-09-24 19:42:21
【问题描述】:
我正在尝试编写一个正则表达式,它将在谷歌表中返回这些结果。单词大写和大小写都在同一个单元格中,包括逗号。我也在寻找一种在 Google 应用程序脚本中完成此任务的方法,但这不是必需的。
"UPPER, Case" =TRUE
"Upper, CASE" =FALSE
"uPPER, case" =FALSE
"UppEr, caSe" =FALSE
"UPPER, case" =TRUE
"uPPer, case" =FALSE
如您所见,仅当整个第一个单词为大写时才返回true。
它还应该忽略逗号和第二个单词。
所以我尝试了这个:
^[A-Z][A-Z]*\W?
^[A-Z] = check first letter to make sure it is a capital letter
[A-Z]* = any amount of the following letters should be capitalized
\W? = ignore anything following and including the first special character (right?)
如果我做错了,请告诉我!我没有得到预期的结果。
【问题讨论】:
标签: regex google-apps-script google-sheets