Regular expressions find and replace – find string and add before/after it without overwriting the found part

The title is a bit of a mouthful, but what I mean is this:

  • I have a bunch of strings likeĀ 180347-003.
  • I want to search for the hyphen and the three numbers after that (and only match when that hyphen + three number pattern exists).
  • I want to replace the hyphen with a comma, but keep the numbers.

What you do is this:

  • In the Find field, put parentheses around the part of the regular expression you want to keep (the three numbers).
  • In the Replace field, put whatever you want to replace and then backslash 1. That treats whatever is in the parentheses as a group and it will take whatever is matched by the regexp inside the parentheses and print that when replacing.
  • RegExp

It’s really not a good explanation but hopefully I can find this again when I need it.

Advertisements

Notepad++ remove duplicate lines

TextFX plugin needs to be installed/enabled from Plugins > Plugin Manager (if it’s installed, the File, Edit… toolbar will have a TextFX option)

Highlight the text to be de-duplicated.

Go to TextFX > TextFX Tools > Sort outputs only UNIQUE … should be CHECKED

Go to TextFX > TextFX Tools > Sort line case sensitive OR insensitive (I don’t think it matters, but choose one option or the other if you specifically want that in your case)

The duplicate lines should now be removed.

 

Create a free website or blog at WordPress.com.

Up ↑