0

I would like to remove strings from a file that already existed in a line with less number suing RegEx(Note++).

Example -

123   = 45,
789 = 321,
123     =   951

Should result in -

123   = 45,
789 = 321,
     =   951
1
  • Unless I'm mistaken, you can't match newlines with regular expressions in Notepad++, so I'm not sure this can be done (unless you used several steps, where you first combine all lines into a single line then perform the replacements). Commented Jan 15, 2013 at 20:10

1 Answer 1

1

Well, this is a good example of how though RegEx is very powerful, it is not always the right tool for the job. For instance, the following RegEx will probably do what you want (I don't have Notepad++ installed, but it works in my RegEx client)

Search: (\b\d+\b)(.+?)\1
Replace: \1\2 (or $1$2, depending on your setup)

This takes and instance of a number, searches until it finds another instance of it, then replaces the entire thing with itself minus the second instance.

However, aside from being pretty dirty, this type of thing would be much simpler using a quick script or even something like Excel.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.