gpt4 book ai didi

regex - sed 匹配日期格式 2013 年 4 月 25 日

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:59:58 25 4
gpt4 key购买 nike

任何人都可以帮助搜索和替换脚本 (sed) 来匹配 2009 年 2 月 24 日的日期并将其替换为空格吗?

 sed 's/ \(Jan\|Feb\|Mar\|Apr\|May\|Jun\|Aug\|Sep\|Oct\|Nov\|Dec\) [0-9][0-9], [2][0-9][0-9][0-9]$//g'

我正在对文件尝试上述语法,但输出似乎不匹配!

最佳答案

你只需要删除$(美元符号):

sed 's/ \(Jan\|Feb\|Mar\|Apr\|May\|Jun\|Aug\|Sep\|Oct\|Nov\|Dec\) [0-9][0-9], [2][0-9][0-9][0-9]//g'

测试你问题中的句子:

kent$  echo "to match a date Feb 24, 2009 and replace it with a white space?"|sed 's/ \(Jan\|Feb\|Mar\|Apr\|May\|Jun\|Aug\|Sep\|Oct\|Nov\|Dec\) [0-9][0-9], [2][0-9][0-9][0-9]//g' 
to match a date and replace it with a white space?

关于regex - sed 匹配日期格式 2013 年 4 月 25 日,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16225271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com