Split the text file line by line using regex

Hello All,

I have a file which is text and using that file I need to get the single line and the line can vary or decrease I have tried one regex method however, in that method I am getting spaces also I do not want the spaces so please any help would be appreciated

The regex which I have used is
(?<=\n\s)[a-z A-Z 0-9 . -]*a-z A-Z 0-9
I want each line
Happy Automation

I have attached the file and desire output which I requireInput.txt (2.8 KB) output.txt (1.6 KB)

Hi @Chirag1991

I think it might be easier if you first do a Regex Replace of 2 or more spaces by a comma. This way you will be much closer to a CSV format which might be more workable :slight_smile:

@Chirag1991 I don’t really understand what you’re trying to do there.

So you have Input.txt, which contains a lot of things: title, title underline, empty rows, lines with 10 columns, lines with 11 columns, lines with 6 columns. Do you want those lines also as text? Do you want them in a DataTable, split by columns? What do you want to do with that input? Why do you think you need a regex?

Here’s a run of the Generate DataTable activity with default properties in preview mode using all of your input file except the first 2 rows (title).

1 Like

Hello I am not using new version so can not use this activity what I am trying to achieve is same output txt file whcih I have attached I want just all lines no space before and after just each lines

What do you mean by “new version”? The Generate Data Table activity has been around for quite some time, I’m sure you have it in the System Activities version you’re using.

Your sample output file also contained spaces at the beginning of lines.

But if what you want is a regular expression that extracts non-whitespace content of each line, you can use a Matches activity with the following advanced regular expression:


Please check Multiline in the RegexOption after providing the regular expression


After that, cycle through the matches and extract match.Group(1) (capturing group #1 in each of the returned matches, where matches is the output of the Matches activity).

My example above resulted in this output:


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