separate to a NEW file
-
how can i separate last 3 words from 200k rows list to a new file ?
i mean 470124, here i want to last 3 digits to a new file, -
@Mostafa-Kamal Please give us the input text or string and the desired output
-
@Mostafa-Kamal said in separate to a NEW file:
i mean 470124, here i want to last 3 digits to a new file,
You use “words” but your example suggests 3 characters. If so then first make a copy of the file as the copied file will contain the 3 characters per line.
Find What:(?-s)^.*(...)$
Replace With:\1
The search mode must be “regular expression”, click on “Replace All” to change the file content.
Each DOT (
.
) character refers to a single character position in the file. The last 3 characters are saved into a group (1) which is written back. The extra characters on each line are effectively removed.Terry
-
if it’s a one-time action, @Terry-R’s suggestion is spot on, and you don’t need to read my post.
However, if it’s an action you are going to take a lot, I would suggest recording a macro:
- Macro > Start Recording
- Search > Mark
- FIND WHAT:
\d{3}$
(this assumes it’s always a digit, like in your example; if it is just the last three characters, whether it’s digit or not, then.{3}$
instead - Uncheckmark Bookmark line
- Checkmark Purge for each search
- Mark All
- Copy Marked Text
- Clear all marks
- Close
- FIND WHAT:
- File > New
- Edit > Paste
- Macro > Stop Recording
- Macro > Save Current Recorded Macro
- Give it a name that makes sense to you (
CopyLastDigitsToNewFile
or something) - Give it a keyboard shortcut if desired.
- Give it a name that makes sense to you (
From now on, you can run the macro to copy those last digits/characters to a new file.