Moo*_*osa 2 java string parsing
我有一个以下格式的字符串
// JCSDL_MASTER b04591342ee71a2baa468d9d2a340ec8 AND
// JCSDL_VERSION 1.0
// JCSDL_START 0980a5f2ef935c4ed153bf975879eac0 twitter.text,contains_any,27-52
twitter.text contains_any "obama, santorum, gingrich, romney, ronpaul, ron paul"
// JCSDL_END
AND
// JCSDL_START f7c18a6fedd90c6b4d77acc14a3a8e5c interaction.type,in,21-29
interaction.type in "twitter,facebook,digg,youtube"
// JCSDL_END
// JCSDL_MASTER_END
Run Code Online (Sandbox Code Playgroud)
我想它最后包含换行符,我只需要获取那些没有启动的行//如何只得到那些行?
非常简单,只需将字符串拆分为单独的行(注意:\n是换行符的转义字符),然后仅在每行开头时才使用它们//
String[] lines = string.split("\\n");
for (String line : lines)
{
if (!line.startsWith("//"))
{
//use the line and do your thing
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9116 次 |
| 最近记录: |