custom search more than "one word + delete" possible?
-
Hello, my name is Tom. I am 40 years old.
Unfortunately, my English is not very good. That’s why I use Google Translator. Don’t be surprised if the grammar is not good ;-)
I would like to briefly describe my problem.I need to delete a part of a library (defined strings). It is a .txt file.
The content of the file describes drawing numbers created for a CAD system and associated customers and much more information. All this information per customer is stored in “one line” (special formatted), not several lines.
Through carelessness, the library has been mixed with that of other systems. Unfortunately, I cannot explain how this happened with the help of a translator. Very, very technical…
Several 500 lines have slipped in between “thousands” of existing lines. The arrangement is arbitrary.I have now exported a list (.txt) that lists the code per customer one after the other. Each customer is assigned a unique code. Each code is generated randomly. It is created without logic.
This list looks something like this:
;
351481
123652
448744
952631
and so on…
;Now to my question:
Is there a way that I can search my library using the code list (scan code by code)? Finally, I would like every line of the library in which a code from the code list is found, to be deleted.
Otherwise I would have to search the entire library “manually” word by word… :-(For example, the library is formatted as follows.
.txt
;
DATA_BEGINNING
CODE 351481 | COMPANY XY | ADDRESS | PHONE | SECTOR | LICENCES | PRODUCT | aso…
CODE 123652 | COMPANY XY | ADDRESS | PHONE | SECTOR | LICENCES | PRODUCT | aso…
and so on…
DATA_END
;Thanks for your time.
Tom
-
@T-H said in custom search more than "one word + delete" possible?:
Is there a way that I can search my library using the code list (scan code by code)?
Yes, although you will need to create a regular expression from the list to mark all the lines and you could then quickly verify the process marked the number in the correct location before deleting them.
The regular expression would look like this:
Find what:
CODE \b(351481|123652)\b
Use the Mark function and tick bookmark lines. The search mode is regular expression. Click mark all.
Since the code numbers appear to be 6 digits and we have 500 if them you will have to do it in a couple of runs since the find what field has a character limit below the length you need. Hopefully you can see that to add more numbers you just put a vertical bar between each number and they all must be inside the
()
characters.Does that sound like something you could try, even if you just tried it with a couple of numbers first.
Terry
-
@T-H
I know you possibly haven’t read my answer, although since it was a bit abbreviated as I was going out I decided to expand on it. Hopefully what I’ve provided in this post will further help you to complete the editing.So if your text file with the codes to be deleted looks like my first image below (the CRLF is the end of line marker, made visible by using View, Show Symbol, Show “end of line” or “show all characters” then you can easily make up the regular expression as I showed it.
Make sure the cursor is at the start of the first code. Use the Replace function to enter into the following fields (search mode is regular expression):
Find What:\R
Replace With:|
Click on Replace All.Now since you will have more characters than can fit into the Find What field you need to break it into 2 roughly equal sized portions. So as long as you don’t exceed 2046 (I think that’s about the maximum number) you will be fine, but easier to just pick 1750-1800 characters in length which should make 2 equal portions. The portion starts with a digit and ends with a digit, so you will need to remove one
|
when you break it into 2 portions.Copy the first portion over top of the example numbers I showed in the first regular expression. Tick bookmark lines and click on Mark All. You will get blue circles alongside each line with one of the codes numbers you are looking for (see another of my images below). You may want to spot check that all seems good. Once confirmed you can delete these marked lines by right clicking on one of the blue cirlces and selecting Bookmark, remove bookmarked lines. Or use the menu option Search, then Bookmark, remove bookmarked lines.
Repeat the process for the 2nd portion of numbers. Your file should now be clear of any of those unwanted code numbers.
Terry
-
@Terry-R
Hello Terry,Thank you very much for the time you have invested in your reply. I really appreciate it.
I will test your suggested solution tomorrow and report back if it worked. But I’m sure it will work ;-)Thank you once again :-)
Tom
-
Hello everyone, I just wanted to let you know that everything worked great. It saved me a lot of work.
I would like to thank you very much ;-)
Tom