1

I need some help with notepad++ and RegEx. I looked for some answers already, but didn't find or understood them. I basically have lines that goes like..

user:$2y$10$Bst0pYRdnpe9kBWTYj925u.VL3ZDuS3lUjxz9SvL/d5UDh6V2A9y:example@mail.com

And I wish to extract the one in the middle section between the : :

1

I wish to extract the text in the middle section between the :s

  • Menu "Search" > "Replace" (or Ctrl + H)

  • Set "Find what" to (.*?:)(.*?)(:.*)

  • Set "Replace with" to \2

  • Enable "Regular expression"

  • Click "Replace All"

    Image

Before:

user:blahblah:example@mail
user:fkdlsfklkdslgkfds:example@mail
user:popbovpxobpfdgfd:example@mail
user:jdspkfokglkf';lkbv';z:example@mail
user:flkdslafeklfkldskf'l:example@mail
user:ddsalfkdlskfl;'dsk:example@mail

After:

blahblah
fkdlsfklkdslgkfds
popbovpxobpfdgfd
jdspkfokglkf';lkbv';z
flkdslafeklfkldskf'l
ddsalfkdlskfl;'dsk

Further reading

  • Wow, it worked! Thank you for the help sir. I'll continue reading further about it and make some small tests. Once again, thanks! – Exid Oct 11 '15 at 9:46
0

I was unable to do it in a single pass try

  • begin search pattern ^[^:]*: empty replace
  • end line search pattern :.*$ empty replace

note that while theorically Posix

search pattern will not work ^[^:]*:\([^:]*\):.*$ by \1

as per Maté's suggestion, this work for me (notepadd++ 6.2.2), tested on OP's sample.

search pattern will not work ^[^:]*:([^:]*):.*$ by \1

  • I couldn't get it to work, basically I have lots of these lines user:$2y$10$Bst0pYRdnpe9kBWTYj925u.VL3ZDuS3lUjxz9SvL/d5UDh6V2A9y:example@mail.com.com – Exid Oct 11 '15 at 6:42
  • Your second attempt is also close, just need to remove \ characters, you shouldn't escape brackets here. – Máté Juhász Oct 11 '15 at 6:48
  • It works, but only give me one results and skip all other lines. Not sure why, but almost there :) – Exid Oct 11 '15 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.