LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match Pattern to extract word from text file

Hi all, I want tried to extract specific word from a text file. For example, I would like to extract "the word" between "<STRING> the word </STRING>". But instead of getting "the word" between them, I get words after </STRING> also. Can anyone help to have a look on my code. Thanks a lot.

 
Download All
0 Kudos
Message 1 of 8
(2,643 Views)

If you'd like us to look at your code, then please attach your code.  An actual VI where the string is saved as default data.

 

You only attached pictures which are things we can't run or debut.

0 Kudos
Message 2 of 8
(2,631 Views)

Sorry that I am new to here. Below attached with my code.

0 Kudos
Message 3 of 8
(2,622 Views)

You didn't save your strings in there as default data.

Nor did you attach the data file.

 

So we have nothing to test your code against.

0 Kudos
Message 4 of 8
(2,615 Views)

Sorry, here is the example txt file.

0 Kudos
Message 5 of 8
(2,611 Views)

The VI you attached doesn't match the picture of your block diagram from your first message.  You through in an extra function, and were looking for  LABEL /LABEL and /STEXT

 

The problem is with the way you are wiring the positions of the string from one to the next.  The Offset after Match means nothing to the next Match Pattern because you aren't acting on the same string.  You are acting on a piece of the original string.  Clean that up and the problem goes away.

 

(Also, it makes more sense to use Build Array and not "Insert" into Array when you are going to append elements at the beginning or end of an array.

 

 

0 Kudos
Message 6 of 8
(2,604 Views)

You could also use Match Regular Expression.

TRANSLATION_BD.png


GCentral
0 Kudos
Message 7 of 8
(2,570 Views)

You could consider one of the existing XML solutions...

 

If that sounds good, I'm sure we can dig up some references.

0 Kudos
Message 8 of 8
(2,565 Views)