公共类测试{
public static void main(String[] args) {
String str = "My CID is #encode2#123456789#encode2# I am from India";
String[] tokens = str.split("#encode2#");
for (int i = 0; i < tokens.length; i++) {
// prints the tokens
System.out.println(tokens[i]);
}
}
}
输出将是我的 CID 是 123456789 我来自印度
但是我只想要整个字符串中的 123456789 并且我想使用该 123456789 数字进行加密。
我也使用 if(!"#encode2#".equals(text)) 条件但仍然没有得到输出。
如何从#encode2#右侧编写条件,如需要策略并在#encode2#之前结束。