I have files file1, file2 contains contents such:
[2017-02-01 10:00:00 start running [error:yes] [doing:no] [finish:] [remind:] [alarmno:123456789] [logno:123456789] [ref:-1:2:-1:-1:-1] [type:2:big issues happen] [flag:0:]]
<--- this line1
Line2:
The same line 1 except date, type, logno and alarmno sometimes contains + or - signs.
... The other lines
I already read all those lines to list of string myLines
.
(Note: the contents of file1 will be the first element of myLines seperated by comma and the second element of myLines will be the contents of file2 seprated by comma and so on.
For exmple this the first element of myLines list:
[2017-02-01 10:00:00 start running [error:yes] [doing:no] [finish:] [remind:] [alarmno:123456789] [logno:123456789] [ref:-1:2:-1:-1:-1] [type:2:big issues happen] [flag:0:],
2017-02-01 10:00:00 start running [error:yes] [doing:no] [finish:] [remind:] [alarmno:123456789] [logno:123456789] [ref:-1:2:-1:-1:-1] [type:2:big issues happen] [flag:0:]]
<--- this the first element of myLines list its the contents of file1 If the file contains one line that mean the first element of myLines list will only contains that line only without comma seprated. I want only
- The date at the first of each lines
- The alarmno(only the digits no, not the word for exmample in the above line: 123456789)
- The logno in the above line (123456789)
- The type for example in the above line the following text (big issues happen)
This what I tried:
String regex = "\\d{2}:\\d{2}:\\d{2}\\s+\\w*\\s+\\w*\\s+\\[\\w*:\\w*]\\s+\\[\\w*:\\]\\s+\\[\\w*:\\]\\s+\\[\\w*:\\]";
String s=null;
for(int i=0; i<myLines.size(); i++)
{
s = myLines.get(i).replaceAll(regex," ");
}
But that result the date and the alarmno:12345... and the other line contents. I even tried to repeat that expression but not help me. Are there any way to implement that in java?