How to check if last line of text file contains one word?


How to check if last line of text file contains one word ? Thx

1 Like

We can use variablename.ToString.EndsWith(“your term”) method


If that doesn’t end with text rather just be there in the last line of the text then
This expression would help you

If the text is stored in str_input

str_output = str_input.Split(Environment.Newline.ToArray()).last.ToString.Contains(“your keyword”).ToString

Cheers @hsendel


Kindly let know for any queries or clarification
Cheers @hsendel .

I tried both Methodes and didn’t work. Could you please help?CheckIfLastLineContainsWord.xaml (6.7 KB) (384 Bytes)

Hello @hsendel
if you want to check the last word then you can use regex Ismatch method to get a boolean value and using this pattern yourword$

check this workflow if you want something like this and to understand more clearly
Ismatch.xaml (5.7 KB)

1 Like

Hello vickydas

I got the follwoing error:

for this error it’s OK : Regex is not declared - #4 by aksh1yadav

@ vickydas,

I tried your code didn’t work (1.8 KB)

Hello @hsendel
The reason that code didnt work is its only checking the last word
i misread it
Try this code it’ll definitely work

System.Text.RegularExpression.Regex.IsMatch((System.Text.RegularExpression.Regex.Regex.Match(Your Variable,".+\z").ToString),"the desired word").ToString

Let me know about it


Working Perfect!!! Thanks a lot vickydas

1 Like

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