How to delete certain items in a text document

0

Basically I have a list of items in the format

item1:item2:item3

and I need to remove all the item1's to make it look like this.

item2:item3

I have most text editors so which ever one suits best let me know, thanks.

(p.s. all of the item's are different, none are the same, including those in the same item catagory)

Joe

Posted 2019-06-05T17:20:29.507

Reputation: 1

So what's common in the items you need to remove? All start at beginning of line and ends at first :? – Máté Juhász – 2019-06-05T17:31:08.263

Its all the items at the beginning of each line that ends before the first : – Joe – 2019-06-05T17:31:29.880

replace *item1:* with *nothing* (and not the text 'nothing') ;^P All editors should be able to do this. – Señor CMasMas – 2019-06-05T17:57:42.023

Sorry for the confusion, the text in the first slot is not "item1" but instead peoples names, it is all one word however. – Joe – 2019-06-05T17:58:54.850

Answers

1

  • Ctrl+H
  • Find what: ^.+?:(.*\R)
  • Replace with: $1
  • check Wrap around
  • check Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

^               # beginning of line
    .+?         # 1 or more any character but newline, not greedy
    :           # a colon
    (.*\R)      # 0 or more any character but newline, followed by any kind of linebreak

Replacement:

$1          # content of group 1 (i.e. everything that is after the first colon)

Given:

item1:item2:item3
item2:item1:item3
item3:item2:item1

Result for given example:

item2:item3
item1:item3
item2:item1

Screen capture: enter image description here

Toto

Posted 2019-06-05T17:20:29.507

Reputation: 7 722

Wow that worked perfectly, how would I go about making the 2nd column rather than the fist? – Joe – 2019-06-05T19:14:45.177

@Joe: Find: :[^:\r\n]+(?=:), Replace: LEAVE EMPTY – Toto – 2019-06-06T09:30:15.637

1

@Joe: If it works for you, Feel free to mark the answer as accepted, How to accept an answer

– Toto – 2019-06-06T09:32:53.973