Android Question Regular Expression

walterf25

Expert
Licensed User
Hello All, i need some help figuring out how to write a regular expression to parse a very specific group of data from a large file, I have tried several patterns that I have found online but non of them return the results I'm trying to achieve.
I have tried the following:
(?<=\{)([^\}]+)(?=\})
But again it doesn't return the results i need.
For example in the image attached i have highlighted the data I need to extract, there are multiple instances of these readings in the file, and the problem is that they are generated at different times depending on a number of events within the firmware, so there isn't really a pattern that I can go by, i have also tried parsing the file line by line and this sort of works but it won't really work 100% as there is another line that I need to look for which could very well happen at the beginning of the file, after a temperature reading or at different random states, so reading line by line is really not the route i would like to stick to, If i could create a regular expression that returns the strings i have highlighted then i could for example parse the lines and check whether the returned group contains for example the word "cam0" if the check returns true then I could somehow go back up to the previous read and extract the temperature readings from this line
[ NO UTC TIME][N: 2845 s][A: 15502 ms][ NORDIC_RPC] GetTemperature response sent: RequestId=6
ExitCode=0
TemperatureResponse{
nordic_temp: 34
amba_temp: 46
wifi_temp: 36
status: TemperatureNormal
}
regex.PNG


Has anyone dealt with this kind of parsing before, i'm really not too familiar with Regular Expressions and i try to avoid it every time i can as I really don't understand much of it, but any help will be greatly appreciated.

If anyone has any ideas, i can send the file I need to parse in a private message.

Thanks,
Walter
 

MarkusR

Well-Known Member
Licensed User
i would split it into chunks.
if u find GetTemperature find start / end behind this key word.
this block read response, read send:
read exitcode, read structure name, find start end, read key values for this structure into a map.
so each sub get a piece of data for processing and return his result in a more handy form.
 
Top