Selphiron
Selphiron

Reputation: 929

Remove text before = character in notepad++

First the text looked like this:

Ab Yz=15,Cd Wx=2,Ef Tu=20,...

I replaced all , with \r\n, so the text looked like this:

Ab Yz=15
Cd Wx=2
Ef Tu=20

Than I wanted only the numbers after the = and replaced ^.+[=] with "blank" and my result was just 20
Does Notepad++ think, that the whole document only has a single line and takes the last = and deletes everything before that?
How can I fix this? Oh and how can I remove the text after the =? (including =)

Edit: I also tried ^.+[\=], ^.+(=) and ^.+(\=) but I got the same result.

Upvotes: 1

Views: 2735

Answers (3)

revo
revo

Reputation: 48711

I guess you have unintentionally checked . matches newline option which makes a . in a regex to go beyond a line - it will match newlines as well (AKA DOTALL modifier). So you should uncheck it.

Also there is no need to do this job in two separate steps. Use regex [^=]+=(\d+),? and replace with \1\n

This will turn such an input string:

Ab Yz=15,Cd Wx=2,Ef Tu=20,Ef Tu=20,Ef Tu=20,Ef Tu=20,Ab Yz=15,Cd Wx=2,Ef Tu=20,Ef Tu=20,

To:

15
2
20
20
20
20
15
2
20
20

Upvotes: 2

Toto
Toto

Reputation: 91430

To change all in one pass, you could do:

  • Find what: (?:^|,)[^=]+=([^,]+)(?:,|$)
  • Replace with: $1\r\n
  • Replace all

Upvotes: 0

gofr1
gofr1

Reputation: 15977

Use Regular expressions in the left-bottom side of Replace window and find ([A-Z]+) ([A-Z]+)= replace with empty string.

More info here.

Upvotes: 1

Related Questions