How to split text file's content based on blank lines?

I’m trying to split and save the content of text file based on blank space, but I don’t see any way to achieve this. My text file contains some data as given below. Can someone guide me on this?

HTML Forms
HTML Forms
HTML Form Attributes
HTML Form Elements
HTML Input Types
HTML Input Attributes
HTML Input Form Attributes

HTML Graphics
HTML Canvas
HTML SVG

HTML Media
HTML Media
HTML Video
HTML Audio
HTML Plug-ins
HTML YouTube

HTML APIs
HTML Geolocation
HTML Drag/Drop
HTML Web Storage
HTML Web Workers
HTML SSE

HTML Examples
HTML Examples
HTML Editor
HTML Quiz
HTML Exercises
HTML Website
HTML Bootcamp
HTML Certificate
HTML Summary
HTML Accessibility

HTML References
HTML Tag List
HTML Attributes
HTML Global Attributes
HTML Browser Support
HTML Events
HTML Colors
HTML Canvas
HTML Audio/Video
HTML Doctypes
HTML Character Sets
HTML URL Encode
HTML Lang Codes
HTTP Messages
HTTP Methods
PX to EM Converter
Keyboard Shortcuts

Hi @surypratap.r

→ Store the input in a variable called Input.
→ Take for each activity to iterate the split text’s, give the below expression,

System.Text.RegularExpressions.Regex.Matches(Input,"([\s\S]*?[A-Za-z]+[\s\s]+)(?=\s+[A-Za-z]+)|((?<=\s+)([A-Za-z]+[\s\S]+))")

→ Inside for each insert the Write Text file activity to write the each split item to each file.
→ Give the name of the file and increase the count to change the name for each file.

Check the below workflow for better understanding,

Regex_Practice.xaml (14.6 KB)

It was working fine for me and check the workflow file and let me know.

Hope it helps!!

2 Likes

Hi @surypratap.r

Read Text File

linesArray = yourText.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)

Thank you so much @mkankatala, it’s working fine. You saved my life :slight_smile:

1 Like

It’s my pleasure… @surypratap.r

Happy Automation!!

1 Like

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