How to open file in java and parse each line

I have a text file containing data like this:

sender id: 1/sequence number: 0/depth: 600/sending time: 13/05/2018
11:17:17 ص/data: Hello I am AUV: 1 this is aggregation # 0 from my
sideEnd-End Delay:0.357072263241232 sender id: 0/sequence number:
0/depth: 700/sending time: 13/05/2018 11:17:17 ص/data: Hello I am AUV:
0 this is aggregation # 0 from my sideEnd-End Delay:0.293693984840975
sender id: 2/sequence number: 0/depth: 500/sending time: 13/05/2018
11:17:17 ص/data: Hello I am AUV: 2 this is aggregation # 0 from my
sideEnd-End Delay:0.421466419584594 sender id: 3/sequence number:
0/depth: 400/sending time: 13/05/2018 11:17:17 ص/data: Hello I am AUV:
3 this is aggregation # 0 from my sideEnd-End Delay:0.486473186901286
sender id: 3/sequence number: 1/depth: 400/sending time: 13/05/2018
11:17:18 ص/data: Hello I am AUV: 3 this is aggregation # 1 from my
sideEnd-End Delay:0.486473186901286 sender id: 1/sequence number:
0/depth: 600/sending time: 13/05/2018 11:17:21 ص/data: Hello I am AUV:
1 this is aggregation # 0 from my sideEnd-End Delay:0.32221205728025
sender id: 0/sequence number: 0/depth: 700/sending time: 13/05/2018
11:17:21 ص/data: Hello I am AUV: 0 this is aggregation # 0 from my
sideEnd-End Delay:0.267329486404354

Each line ends with the end-end delay, for example line#1:

sender id: 1/sequence number: 0/depth: 600/sending time: 13/05/2018
11:17:17 ص/data: Hello I am AUV: 1 this is aggregation # 0 from my
sideEnd-End Delay:0.357072263241232

I need to divide this file into others files where each file corresponding to a specific sender id.

Each file will contain the end-end delay values for each sender id only such as 0.357072263241232.

I have 4 senders so 4 files will be generated …

Any help or any hint please ?

I don’t have the experience with regex!

Answer

Try Regex: sendersid:s(d+).*?End-EndsDelay:(d+(?:.d+)?)

Demo

Group 1 will have the sender id

Group 2 will have the end – end delay value

Leave a Reply

Your email address will not be published. Required fields are marked *