9

I have a SQL dump with expressions such as youtubehd:2nj6bykw. The 2nj6bykw can also be a different random string. It is always 8 characters long.

I want to replace youtubehd:2nj6bykw with just youtubehd.

How can I do this without replacing it manually, one by one? The SQL dump is over 230000 lines long and has about 200 occurrences of these strings.

I suppose I need a wildcard, but I have no clue about what it is and how I can do this.

1 Answer 1

15

Please make sure you have a backup in case something goes wrong.

  • In Notepad++ go to Search → Replace
  • In the Find What textbox paste the following: youtubehd:\w\w\w\w\w\w\w\w
  • In the Replace With textbox paste the following: youtubehd
  • Ensure that Search Mode is set to Regular expression
  • Click Replace All

Thanks to KCotreau for pointing out that search mode defaults to Normal and needs to be changed.

Edit:

It's been pointed out in the comments below that you could instead use youtubehd:\w{8} as your search pattern. This is correct and indeed preferable. Support for this was only added in Notepad++ v6 though which came out after this was originally written hence the reason why I used the longer form. See here for more.

4
  • 1
    +1 I have been beating myself up trying to figure this out. It should be so simple, but it was not easy to find. I tested this and it does work. I would add: Choose "Regular Expression" for the search type.
    – KCotreau
    Jul 21, 2011 at 13:15
  • More elegant would be: youtubehd:\w{8} for fixed lenth and youtubehd:\w* for any
    – AndriuZ
    Sep 6, 2017 at 16:13
  • @AndriuZ: I was aware of the \w{8} syntax but to my knowledge Notepad++ didn't support it at the time and I believe it was added in a later version. I'll probably update the answer to reflect this at some point.
    – James P
    Sep 6, 2017 at 16:22
  • @James P it worked when I tested on Np++ 7.4.2 32bit
    – AndriuZ
    Sep 6, 2017 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .