日志文件的这些模式在一行中出现多次。例如文件可能看起来像
dsads utc-hour_of_year:2013-07-30T17 jdshkdsjhf utc-week_of_year:2013-W31 dskjdskf
utc-week_of_year:2013-W31 dskdsld fdsfd
dshdskhkds utc-month_of_year:2013-07 gfdkjlkdf
我想用“Y”替换所有日期特定信息
我试过:replaceAll("_year:.*\s", "_year:Y");` 但它会删除第一次替换后发生的所有内容,因为 .* 的贪婪匹配
dsads utc-hour_of_year:Y
utc-week_of_year:Y
dshdskhkds utc-month_of_year:Y
但预期的结果是:
dsads utc-hour_of_year:Y jdshkdsjhf utc-week_of_year:Y dskjdskf
utc-week_of_year:Y dskdsld fdsfd
dshdskhkds utc-month_of_year:Y gfdkjlkdf