我有一个 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/