how to use sed delete Unicode in some range?

后端 未结 2 1683
孤独总比滥情好
孤独总比滥情好 2021-01-05 22:10

I want to remove Unicode in some range, e.g.:

echo \"abcABC123\" | sed \'s/[\\uff21-\\uff3b]//g\'

expect \"abc123\", but get:

2条回答
  •  感情败类
    2021-01-05 22:58

    Unicode support in sed is not well defined. You may be better off using command line perl:

    echo "abcABC123" | perl -CS -pe 's/[\x{FF21}-\x{FF3B}]+//g'
    
    abc123
    

    It is important to use -CS flags here to be able to get correct UTF8 encodings for input/output/error.

提交回复
热议问题