Parse string in Java
java, parsing, string
Solution
Pretty simply, just split up the string into individual lines (note: `\n` is an escape character for a line break), then only use each line if it does not start with `//`
String[] lines = string.split("\\n");
for (String line : lines)
{
if (!line.startsWith("//"))
{
//use the line and do your thing
}
}
Problem
I have a string in below format ``` // 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 ``` I suppose it include newline character at the end, i need to just get only those line which is not being started by // how to get only those lines?