提取部分字符串的紧凑方式(FASTA 标头)
给定以下字符串:
string Header =">day11:1:356617";
如何提取除“>”之外的所有内容, 仅产生:
day11:1:356617
我可以对字符串字符进行标准循环 并仅保留“>”以外的内容。
string nStr ="";
for (int i=0; i < Header.size(); i++) {
if (Header[i] != ">") {
nStr = nStr + Header[i];
}
}
但该方法似乎 太笨拙和缓慢,特别是我需要这样做 提取数百万行。
Given the following string:
string Header =">day11:1:356617";
How do you extract everything except ">",
yielding only:
day11:1:356617
I could do standard loop over the string character
and keep only other than ">".
string nStr ="";
for (int i=0; i < Header.size(); i++) {
if (Header[i] != ">") {
nStr = nStr + Header[i];
}
}
But the approach seems
too clumsy and slow, in particular I need to do such
extraction for millions of lines.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
...您没有说任何关于入站字符串的“域”或您想要剪切的内容。 如果它只是您给出的形式的字符串,这将是最快的:
...You didn't say anything about the "domain" of the inbound strings or what you're looking to chomp. If it's just strings of the form you gave, this would be the fastest: