Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试删除所有非字母数字字符和非空格字符以及非破折号非下划线字符
echo "$1" |sed 's/[^a-zA-Z0-9[:space:]]//g'
我想要一些像
echo "$1" |sed 's/[^\-\_a-zA-Z0-9[:space:]]//g'
如何将两个正则表达式规则混合在一起?
样本输入是:
a-b a_b ab a.. a.b a b a %b a ^&n
我想要这个输出:
a-b a_b ab a ab a b a b a n
这适用于 GNU sed:
sed 's/[^-_a-zA-Z0-9[:space:]]//g' file
$猫文件 抗体 a_b 抗体 一个.. 抗体 抗体 %b 一个^&n $ sed 's/[^-_a-zA-Z0-9[:space:]]//g' 文件 抗体 a_b 抗体 一个 抗体 抗体 抗体 一个