使用SED删除没有重复引用的重复字符 [英] Delete Repeated Characters without back-referencing with SED
本文介绍了使用SED删除没有重复引用的重复字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我们有一个包含
HHEELLOO
HHYYPPOOTTHHEESSIISS
,我们要删除重复的字符.据我所知,我们可以使用
and we want to delete repeated characters. To my knowledge we can do this with
s/\([A-Z]\)\1/\1/g
这是一个家庭作业问题,这位教授说他希望我们尝试练习而不使用反向引用或扩展正则表达式.这可能吗?如果有人能指出正确的方向,我将不胜感激!
This is a homework problem and the professor said he wants us to try the exercises without back-referencing or extended regular expressions. Is that possible on this one? I would appreciate it if anyone could point me in the right direction, thanks!
推荐答案
这是一种方法:
s/AA/A/g
s/BB/B/g
...
s/ZZ/Z/g
单线:
sed 's/AA/A/g; s/BB/B/g; ...'
这篇关于使用SED删除没有重复引用的重复字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文