Phantom Fortnite
Phantom Fortnite

Reputation: 27

REGEX NOTEPAD ++

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

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

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:

enter image description here

Upvotes: 1

Related Questions