LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time for another game of "Fix My Rube"

Usually in these situations, things can be simplified so I figured I'd come here to ask if anyone sees a better way. I basically have some delimiters (which may or not be in the search string string) and I need to grab the text between each set of delimiters. The search and replace is probably inefficient, at best, and it would be nice to stick it all in one loop, possibly using shift registers but I couldn't quite get it working as I wanted.

 

0 Kudos
Message 1 of 19
(4,824 Views)
Download All
Message 2 of 19
(4,814 Views)

A slightly modified version of Christen's which will allow the last item to have a delimiter after it. The above version will give you an empty string in the last entry of the array.

 

Token Parser.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 3 of 19
(4,807 Views)

@Mark_Yedinak wrote:

A slightly modified version of Christen's which will allow the last item to have a delimiter after it. The above version will give you an empty string in the last entry of the array.


Mine works fine with the given default data. 😄

 

If you know that you are always looking 2 items, you can even use a FOR loop for even better efficiency. 😉

Message 4 of 19
(4,801 Views)

@altenbach wrote:

@Mark_Yedinak wrote:

A slightly modified version of Christen's which will allow the last item to have a delimiter after it. The above version will give you an empty string in the last entry of the array.


Mine works fine with the given default data. 😄

 

If you know that you are always looking 2 items, you can even use a FOR loop for even better efficiency. 😉


I tried both since Greg mentioned the delimiter may or may not be there. My first attempt was exactly the same as yours. I modified after I added the last delimiter.

 

I also tried to use a regular expression. It would work provided you didn't have any longer delimiters which contained a shorter delimiter such as the "P" and "1P".



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 5 of 19
(4,795 Views)

Loops? Bah!

 

ParseDelimiters.png

 

Regex greediness will typically handle cases like P and 1P gracefully.

Message 6 of 19
(4,787 Views)

Well, this code is not the same, for example if you have consecutive delimiters, you generate empty elements while scan string for tokes contracts successive delimiters into one by default.

 

For example with an input string of "P34a1PPPP9ac"

 

I still get [34a, 9ac] while you would get [34a, (blank), (blank), (blank), 9ac]

 

(Of course we don't have enough information to decide what's correct .... ;))

 

 

(... maybe if this idea would get implemented .... ;))

Message 7 of 19
(4,782 Views)

Add a '+' to the end of the regex, problem solved.

Message 8 of 19
(4,767 Views)

@Darin.K wrote:

Add a '+' to the end of the regex, problem solved.


 

🙂

0 Kudos
Message 9 of 19
(4,737 Views)

@altenbach wrote:

 

I still get [34a, 9ac] while you would get [34a, (blank), (blank), (blank), 9ac]

 

(Of course we don't have enough information to decide what's correct .... ;))

 


Thanks guys. These delimeters are gotten from a specific barcode standard and act as prefixed idenifiers on the following data. Encoding will have been done on the data so I believe I shouldn't have consecutive delimiters. I have to assume the encoding takes care of all this, to avoid the issues of the data itself containing any character strings that match standardized identifiers, as this could confuse any parser (although I haven't read up on it much to this point so I don't know for sure yet). This is more than enough to get me started. Appreciate it.

0 Kudos
Message 10 of 19
(4,736 Views)