0

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!

2
  • Question: Are you certain that each line does not already end in a newline or carriage return? Commented May 20, 2018 at 16:10
  • each line end by a new line and at the end of each line there is a double value ... Commented May 20, 2018 at 16:17

1 Answer 1

1

Try Regex: sender\sid:\s(\d+).*?End-End\sDelay:(\d+(?:\.\d+)?)

Demo

Group 1 will have the sender id

Group 2 will have the end - end delay value

Sign up to request clarification or add additional context in comments.

2 Comments

How to use it with open file method and store the result in the correct file with append option?
I'm afraid, I'll not be able to help you much with the exact Java code. This link could be a starting point for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.