• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Delete a line from txt file

New Here ,
Apr 17, 2007 Apr 17, 2007

Copy link to clipboard

Copied

Is it possible to search for a string in a text file then delete the line where the string is found.

For ex. if I have a list of names in a text file, I would like to be able to search for a name, based on user's input, then if the name is found, delete the line where the name was listed at.

Thanks
TOPICS
Advanced techniques

Views

249

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 17, 2007 Apr 17, 2007

Copy link to clipboard

Copied

Is each name on a separate line? If so, each line is terminated with a <BR>, </P>, etc. (unless it is in its own table cell).

Then one way to handle it would be to convert the line terminator to a pipe ( | ) character, giving you a pipe delimited list. The ListFind( ) function could be used to find the list element that has the name in it and the ListDeleteAt( ) function deletes the name.

Sample code below. There are other ways to handle it if the lines are in their own individual table cell.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 19, 2007 Apr 19, 2007

Copy link to clipboard

Copied

LATEST
See code sample below.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation