How to remove lines in text file

Hi guys, I have a problem here. I have some text files, but i want to remove some of the lines in the text files. May I know how can I do it? I wish to remove all the lines below “Abbreviation”. Also note that there are coutless line above “Abbreviation”, the data show below is a shortened one.

Example of my text file:
Name: Panda1
Role: Director
Adress: hello panda, street 51
postal code: 123456

Abbreviation

UL - Local Entity not registered with ACRA

UF - Foreign Entity not registered with ACRA

AR - Annual Return

AGM - Annual General Meeting

FS - Financial Statements

FYE - Financial Year End

OSCARS - One Stop Change of Address Reporting Service by Immigration & Checkpoint Authority.

Authentication No. : L21057849820O

Page 3 of 4ACCOUNTING AND CORPORATE REGULATORY AUTHORITY
(ACRA)

WHILST EVERY ENDEAVOR IS MADE TO ENSURE THAT INFORMATION PROVIDED IS UPDATED AND CORRECT. THE AUTHORITY
DISCLAIMS ANY LIABILITY FOR ANY DAMAGE OR LOSS THAT MAY BE CAUSED AS A RESULT OF ANY ERROR OR OMISSION.

Business Profile (Company) of HELLO INTERNATIONAL PTE LTD (1999901281) Date: 30/01/1999

Note :

  • The information contained in this product is collated from lodgements filed with ACRA, and/or information collected by other government sources.

  • The list of officers for this entity is available for online authentication within 30 days from the date of purchase of this Business Profile. Please scan
    the QR code available on the last page of this profile to access the authentication page. For more information, please visit www.acra.gov.sg.

FOR REGISTRAR OF COMPANIES AND BUSINESS NAMES
SINGAPORE

RECEIPT NO. : ACRA2101290342224 (Free Business Profile by ACRA)

DATE : 30/01/1999

This is computer generated. Hence no signature required.

Authentication No. : L2105678899

Page 4 of 4

You can use split to take the text you need:

Split(myTextString, “Abbreviation”).First

This cuts your text into 2 pieces: text before the word “Abbreviation”, and the text after. If you need the text before “Abbreviation”, you use .first

@Leo88 if this worked for you, could you mark my post as the solution? Thanks!

Hi

Another solution that ensures that it trims the extra spaces as well

If the above string is in a variable named strinput

Then use a Assign activity and mention like this

stroutput = Split(strinput.ToString,”Abbreviation”)(1).ToString.Trim

Where stroutput is a string variable

Here split method is used which is used to split the text between Abbreviation

(1) denotes the next part of Abbreviation

Cheers @Leo88

thanks, it worked!

I have encountered another problem. This time I want to remove the lines below which are in the middle of the whole text file:

Note :

  • The information contained in this product is collated from lodgements filed with ACRA, and/or information collected by other government sources.
  • The list of officers for this entity is available for online authentication within 30 days from the date of purchase of this Business Profile. Please scan
    the QR code available on the last page of this profile to access the authentication page. For more information, please visit www.acra.gov.sg.

Any idea on how I can do this?

@Leo, in the future, could you mark my post as the solution if it worked, and create a new post with your new issue? This helps us track issues and solutions more efficiently.

Here’s the solution that would cover your new issue. Make sure you have System.Text.RegularExpressions listed in your imports.

In an assign activity:

myString = regex.replace(myString, "Note[\S\s]+www\.acra\.gov\.sg\.",string.empty).trim

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