Reputation: 27
I have a list in this format
FIRSTTEXT:SECONDTEXT:RANDOMTEXT::::::::RANDOMNUMBERS:NUMBER:
but all the text is not in this format. i want to save only FIRSTTEXT:SECONDTEXT, firsttext and secondtext are in the same position on all document !
I have tried this one:
Find what: (.+):(.+)
Replace with: \1:\2
However, it doesn't work.
Upvotes: 1
Views: 45
Reputation: 626802
You may use
Find What: ^(?:([^:\s]+:[^:\s]+).*|.*\R*)
Replace With: $1
Details
^
- start of a line(?:
- start of a non-capturing group:
([^:\s]+:[^:\s]+)
- Group 1 ($1
refers to this value):
[^:\s]+
- 1+ chars other than whitespace and :
:
- a colon [^:\s]+
- 1+ chars other than whitespace and :
.*
- 0+ chars other than any line break char, as many as possible|
- or
.*
- 0+ chars other than any line break char, as many as possible\R*
- 0+ line break sequences)
- end of the non-capturing group.Demo and settings:
Upvotes: 1