正则表达式删除所有大写字母和后面的逗号

标签 regex openrefine

我有一个 csv 名称,例如 Smith、SMITH、John、JOHN,我尝试在 OpenRefine 中使用正则表达式来删除全部大写的名称。

replace(value,/^[A-Z]$/, '') 不执行任何操作,并且 replace(value,/[A-Z]/, '') 被删除包含所有大写字母的名称,并留下一串逗号。

我需要删除全部大写的名称以及后面可能出现的所有逗号。我对通过将所有名称设为小写或将每个名称的第一个字母大写来保留列表不感兴趣。任何全部大写的名称都必须删除。

最佳答案

使用

replace(value, /, *[A-Z]+\b/, '')

参见proof .

说明

--------------------------------------------------------------------------------
  ,                        ','
--------------------------------------------------------------------------------
   *                       ' ' (0 or more times (matching the most
                           amount possible))
--------------------------------------------------------------------------------
  [A-Z]+                   any character of: 'A' to 'Z' (1 or more
                           times (matching the most amount possible))
--------------------------------------------------------------------------------
  \b                       the boundary between a word char (\w) and
                           something that is not a word char

关于正则表达式删除所有大写字母和后面的逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66768727/

相关文章:

python - 打印给定字符串中两个特定单词之间的单词

javascript - 仅匹配 <br> 如果直接在 </p> 之前但不直接在 </p> 之后

json - 使用 OpenRefine(或 R)解析大而复杂的 Json 文件的最佳方法

json - 谷歌优化 : iterate over a JSON dictionary

random - 如何在Openrefine中进行随机样本?

java - 替换字符串 java Scanner 类

PHP 使用正则表达式分解字符串

java - Oracle 数据库 12c : How to also get the result index from a contains search

openrefine - 仅通过包含空白/空字符串单元格进行过滤