NEED to ADD a new line in a text file using REGEX

example file.txt (1.2 KB)
Need to add a new line in the given below attachment . where it has to be add .before the starting of a new header.
Wanted to have new line space in between the following the header given in the file:
Out of Pocket (Stop Loss)
Deductible
Co-Payment
Co-Insurance
Need to give new line space between the following headers where the last value given is not standard the value might get changed.

HI @Renuka_M

Can you share the Expected output?

Regards
Gokul

HI @Renuka_M

Correct me if im wrong

you want something like this?
image

Regards
Gokul

example file.txt (1.2 KB)
Not like that . i have attached the expected output file.

Thanks for a fast reply @Gokul001

So the coverage level is constant , right?

only the headers will be the same and the internal values will be differing . i have just given u an example for it . i have many files with different values . the end value before each header will be different value. for coverage level after the : value changes . its not constant.

Okay @Renuka_M

Try this expression
System.Text.RegularExpressions.Regex.Replace(“textFileVariable”,"^(?=\S.+\nCoverage\sLevel)","\n")

Regards
Gokul

example file.txt (529 Bytes)
@Yoichi
i will check with the solution u have given. i have another doubt i am attaching another example . in that after out of pocket paragraph the value given is not constant value and v dont know what value will be given below for that how to create an new line space. can u please give solution

This is another example for the above asked query:
This is also another example which i have asked…the below given value after the out of pocket full value after that the given below value is not constant the value changes continuously…need a solution for that.

Out of Pocket (Stop Loss)
Coverage Level: xxxx
Service Type: rrrrr
Insurance Type Code: rrrr (xxx)
Time Period Qualifier: rrrrr
Amount: $16,190.82
In Plan Network Indicator: Unknown

Non-Covered
Coverage Level: xxxx
Service Type: xxxxxx
Insurance Type Code: rrrrr (xxx)
Plan Coverage Description: rrrrr
In Plan Network Indicator: No
Message: bbbbb
Non-Covered
Coverage Level: dddddd
Service Type: vvvvvv
Insurance Type Code: nnnnn
Plan Coverage Description: llllll
In Plan Network Indicator: No
Message: ffffffi

Hi @Renuka_M

Try this expression

System.Text.RegularExpressions.Regex.Replace(“textFileVariable”,"^(?=\S.+\nCoverage\sLevel)|^(?=\S.+\nNon-Covered\s)","\n")

Regards
Gokul

@Gokul001
Below out of pocket the value of non-covered is not fixed they are almost 15 types of header value which will be changing in different files . so i want a syntax where whatever value comes in place of “Non-covered” value so i need to get only the out of pack value. but the header has only text value

Hi @Renuka_M

In this case, If the Input file has any static value.

Regards
Gokul

yes the input file has static value it wil be changing randomly afterr the outof pocket header
@Gokul001