根据特定图案分割线
我有如下文本:
HWI-ST150_0129:2:8:19270:131483#0 chr1 735440 819383 HWI-ST150_0129:5:44:4612:112201#0 chr1 735446 819377 HWI-ST150_0129:5:61:12668:134666#0 chr1 735444 819380
HWI-ST150_0129:2:27:6777:92418#0 chr10 107950655 107951635 HWI-ST150_0129:3:61:5129:81938#0 chr10 107950674 107951702
......
所以我们可以看到每一行都包含类似“HWI-ST150_0129:2:8:19270:131483#0 chr1 735440 819383”的模式 我希望把它变成:
HWI-ST150_0129:2:8:19270:131483#0 chr1 735440 819383
HWI-ST150_0129:5:44:4612:112201#0 chr1 735446 819377
HWI-ST150_0129:5:61:12668:134666#0 chr1 735444 819380
HWI-ST150_0129:2:27:6777:92418#0 chr10 107950655 107951635
HWI-ST150_0129:3:61:5129:81938#0 chr10 107950674 107951702
我该怎么做? bash 和 python 都可以。 我个人更喜欢bash 谢谢
I have a text like below:
HWI-ST150_0129:2:8:19270:131483#0 chr1 735440 819383 HWI-ST150_0129:5:44:4612:112201#0 chr1 735446 819377 HWI-ST150_0129:5:61:12668:134666#0 chr1 735444 819380
HWI-ST150_0129:2:27:6777:92418#0 chr10 107950655 107951635 HWI-ST150_0129:3:61:5129:81938#0 chr10 107950674 107951702
......
So we can see each line contains the pattern like "HWI-ST150_0129:2:8:19270:131483#0 chr1 735440 819383"
I hope to make it into:
HWI-ST150_0129:2:8:19270:131483#0 chr1 735440 819383
HWI-ST150_0129:5:44:4612:112201#0 chr1 735446 819377
HWI-ST150_0129:5:61:12668:134666#0 chr1 735444 819380
HWI-ST150_0129:2:27:6777:92418#0 chr10 107950655 107951635
HWI-ST150_0129:3:61:5129:81938#0 chr10 107950674 107951702
How can I do it? Both bash and python ok.
I personally like bash more
thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用什么语言或代码?
查找字符串中每个 HWI 的索引。
在 HWI“\r”或“\r\n”之前插入基本上是插入一个重新调整字符和换行符。
可能还想研究一下 REGEX。
What language or code are you working in?
Find the index of each HWI in the string.
The insert right before the HWI "\r" or maybe "\r\n" basically inserting a retun char and newline.
May want to look into REGEX as well.
您没有指定工具或语言...
工具 (Windows):使用 Notepad++ 并使用以下正则表达式进行替换:
搜索:
替换为:
语言(任何操作系统):使用 Perl 和给定的正则表达式。替换正则表达式应该是:
You didn't specify a tool or language...
Tool (Windows): use Notepad++ and use the following regex for replacing:
Search:
Replace with:
Language (any OS): use Perl and the given regexes. The replace regex should be:
这将为您提供准确的结果
This will give you the exact result