02-10-2020 08:24 PM
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.
02-10-2020 08:41 PM
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.
02-10-2020 09:27 PM
Sorry that I am new to here. Below attached with my code.
02-10-2020 10:04 PM
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.
02-10-2020 10:12 PM
Sorry, here is the example txt file.
02-10-2020 10:30 PM - edited 02-10-2020 10:32 PM
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.
02-11-2020 02:46 AM
02-11-2020 03:08 AM
You could consider one of the existing XML solutions...
If that sounds good, I'm sure we can dig up some references.