Remove arbitrary Text up to certain Word from Text File
Question by Mail Request | Last update on 2022-10-20 | Created on 2014-07-11
I have several text files, that have approximately the following structure:
Arbitrary text including arbitrary information Author: arbitrary name Any other random text
I would like to remove the "header" from those files. Everything before the word "Author" belongs to the header. The difficulty is that the information given in the header can differ and are not always the same, so that I cannot use the normal "Search and Replace" function.
After the replacement, my file should look like this:
Author: arbitrary name Any other random text
How can I use the TextConverter tool to delete all characters and words from the start/beginning of a file up to a certain string?
Related Topics
PHP: Remove arbitrary Characters at the Beginning and the End of a String
Tutorial | 0 Comments
MySQL: Combine full text search with LIKE search for words with 3 letters
Tutorial | 2 Comments
Rename File to its Folder Name
Tutorial | 0 Comments
PHP: File Download Script
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
CSS: Include CSS Stylesheets in HTML
Tutorial | 0 Comments
Lord's Prayer in 20 other Languages
Info | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Update: The TextConverter has been further developed since my old answer and now contains a function with which this task can be carried out directly without having to use regular expressions:
Of course, also in the latest version of the TextConverter, my old answer retains its validity and you can continue to alternatively solve this task with the functions "replace with regular expressions" and "deletion of lines".
I have therefore attached my old answer, in which I have explained those steps, under this answer:
2022-10-20 at 23:33
Old Answer (still valid):
This task can be done in the TextConverter, for example with using regular expressions.
By replacing ".*(Author.*)" with "$1", you should get your desired result. The regular expression in the search box finds arbitrary characters up to the word "Author" and arbitrary characters after this word. The $1 in the replace box, replaces with the characters, that has been found in brackets - that is everything except the characters written before "Author".
Alternative: If your header should have a fixed number of lines, you can also use the function "Actions > Lines > Delete Lines". Here you can enter for example "1-3", "1,2" or "1" in the field "Delete Lines according to Line Numbers" (counted from the beginning) to remove the specified lines from the beginning of the text file.
PS: You should always have a look at the preview to ensure, that the result is as desired, before storing the file.
Last update on 2022-10-20 | Created on 2014-07-11