How do you parse text?

how to parse text? ##name1 220\n ##name2 250\n ##name3 350\n +N. the key element of the end of the line is the character \n. Each line always ends with a newline character \n Static names - dynamic data only 220 250 350... if the length of one line is easy to determine by the newline character \n , then the next one becomes difficult because I cannot search for the character \n from the end . Text " ##name2 250\n" get text by key static text "##name2" the beginning of the next line is not always "##name3" maybe the text will be next" ##name1 .........\n"

I have included an image for an example. this is part of an example project. In fact, text is parsed from the bluetooth com port, there the text always appears new in such an example as I indicated above

Generally like this

In your case it might be easier to convert the string into a list using the list from csv table block and then remove the name of each item using the replace all block


I like the text split block for this.

First split the text at \n, to get a list of lines.
Then for each line in the list of lines, split the line at ' ' to get a list of line parts.
Item 1 is ##name and item 2 in each list is the number.

In that case, you can get the text one line at a time by specifying a BlueTooth Delimiter of 10, and requesting -1 bytes of text each Clock.Timer cycle where bytes available > 0.

You can also feed that data stream directly into an AI2 Graph component and GraphData subcomponents if you specify tags of ##Name1, ##Name2,...

thank you for your help - I caught the idea until I tried it. I used a similar method to yours, but did not provide it here as a sample. I ran into a problem when a large data packet had to be parsed - it did not always process them successfully. It happened that he simply does not see the data, although they are in the array. The problem is that if he sends one line, he works it out well (parses), and if in one data packet consisting of 5 lines, then there was a problem. Thank you. I will try your method later, maybe it would suit me too. For now, I will focus on the method from Taifun

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.