问题描述
我有一个像 cat: f: No such file or directory
shell returned 1
这样的名称的 csv,我正在尝试在 OpenRefine 中使用正则表达式来删除所有大写的名称。
Smith,SMITH,John,JOHN
什么都不做,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