What does this definition of contiguous subsequences mean?
我正在解决问题,但我不了解连续的子序列是如何工作的。例如,
Finding all 3 character length substrings in a string
public class Subsequences {
public static void main(String[] args) {
String s = "CCAATA CCGT";
String ss = s.replaceAll("\\s+","");
int n = 4; // subsequences of length
for (int i=0; i <= ss.length() - n; i++) {
String substr = ss.substring(i, i + n);
if (substr.matches("[a-zA-Z]+")) {
System.out.println(substr);
}
}
}
}
输出:
CCAA CAAT AATA ATAC TACC ACCG CCGT
有人会向我解释这个循环是做什么的吗?
for (int i=0; i <= ss.length() - n; i++) {
String substr = ss.substring(i, i + n);
if (substr.matches("[a-zA-Z]+")) {
System.out.println(substr);
}
}
答案 0 :(得分:0)
确保子字符串仅包含字母(无空格)