The answer is probably yes, but we'd need more details about the following text.
On the other hand, it probably would be much simpler to include the text as another field in the data file.
The following text is technical, and varies, such as
AWS/ASME-SFA A5.18 ER70S-6
AS/NZS 14341-B G 49A 3U C S6, G 49A 3U M S6
I could only see it working if it was possible to test in a very general sense if there was text there or not.
I know I could add label fields in Excel, but it's a pretty complex spresdsheet already and I was hoping to avoid adding more columns to it if possible. It's frustrating that this sort of conditional stuff is easy in something like Word but InDesign's merge functionality is practically unchanged from the it's origins in Pagemaker.
ID does have Conditional Text, which may also be another option. Conditonal text is shown or hidden globally, and the same text can, I believe, carry more than one condition.
But that still leaves trying to test to apply the conditions, or doing it manually (by some sort of code in the data) before the merge. If you know all of the possible combinations of following text I'm sure this can be scripted, but the effort involved is probably more than adding the columns to the spreadsheet.
Thanks for the suggestions Peter, I had looked into conditional text but as I understand it is more akin to layers. You create a condition yourself, apply it to a text selection and then make that condition visible or not literally like a layer within a text block. Good for language variations etc in one document but I don't think it can be used for this.
If I put a code in the data source then I may as well just add the labels.
And as the data varies quite a lot I was after a general test for non empty state rather than scripting in tests for every specific text variation. Looks like I'll just have to add more columns to my spreadsheet. Groan, 800+ line items.
So maybe I'm not really understanding the problem.
You can use a look-ahead in GREP, perhaps, but I'm not quite sure what you want to look for. You could find blank lines, but it would be difficult to differentiate between different non-blank lines.
Maybe using unique paragraph styles for each label? GREP can't find text in one style followed by another, but scripting can, I think.
I was basically wanting to test if the line has text in it put in the label, if it's empty no label. I understood this would mean a separate paragraph style for each type. In the end I just added extra columns for the label names in excel and added extra field in Indesign.