Reputation: 65
I have a table in notepad++ which I try to format and get rid of some digits and points. The table looks something like this:
line_a . . 47 34 54 33 44
line_b . . . 43 76 23 44
line_c . . . 32 56 12 34
line_d . 33 87 65 12 23 21
line_e 44 32 76 . . . .
What I want to do is to look for the first three entires in each line (no matter if it is a - or a digit) and remove them so that in the end I get this table:
line_a 34 54 33 44
line_b 43 76 23 44
line_c 32 56 12 34
line_d 65 12 23 21
line_e . . . .
And second I want to look for a line with no digits at all (the last one in this example) and remove it complety.
Can anyone help me? Thanks a lot!
Upvotes: 0
Views: 1029
Reputation: 6925
Go to Search > Replace
menu (shortcut CTRL+H) and do the following:
Find what:
^(?:[.\d]+\s){3}(?:[ .]+$)?(.*)
Replace:
$1
Select radio button "Regular Expression"
Then press Replace All
This will remove the first 3 columns and at the same time will remove completely the points-only lines. You can test it, have it explained and see the results for your specific example at regex101.
Upvotes: 0
Reputation: 21381
Search for ^(\s*[^ ]+){3}(.*)$
and replace with \2
^
-> beginning of line
(\s*[^ ]+){3}
-> 3 groups of strings that may (or not) include space/tabs in front of them.
(.*)$
-> group the rest of the line in group number 2 that we use to replace ($
denotes the end of line)
Upvotes: 0
Reputation: 61
Search for ^([^ ]+)( [^ ]+){3}
and replace it with $1
.
This will find the first four strings without a space on each line and replace them with the first of those four strings.
Upvotes: 1