I am reading a pl/sql code from a text file and storing all words of it into array list from below code :
Scanner in1 = new Scanner(file1);
ArrayList<String> Code1 = new ArrayList<String>();
in1.useDelimiter("/\*[^*]*\*+(?:[^/*][^*]*\*+)*/|[\p{javaWhitespace}\.|,]+");
while (in1.hasNext())
{
Code1.add(in1.next().toLowerCase());
}
Everything is working fine but i am facing issue whenever there is a comments section in code written in after special character -- Like below:
select * from
Dummy_Table --This is a, dummy.table
where id = 1 -- Filter.on, id
For above code i don't want to store the comments (--This is a, dummy.table) and (-- Filter.on, id) in my list.How can i do this ?
in1.useDelimiter("/\*[^*]*\*+(?:[^/*][^*]*\*+)*/|[\p{javaWhitespace}\.|,]+");
I am using above delimiter to skip reading comment section enclosed between /* and */, which is multiple line comments as written below but including this i also want to skip reading/storing the single statement comments i.e. after -- till the end of line.
/*
|| This is a comments section in pl/sql code...||
|| Which i don't want to store.. ||
*/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…