-1

I have a text document on notepad++ filled with things

V307G5C
V307G57
V307G5X
V307G54
V307G57
V307G5Y
V307G58
V307G5L
V307G56
V307G5M

And I want them to be like this

V307
V307
V307
V307
V307
V307
V307
V307
V307
V307

How do I achieve this?

Thank you!

Iloveregex
  • 11
  • 3
  • 1
    Does this answer your question? [Notepad++: Delete everything after a number of characters in string](https://stackoverflow.com/questions/28124538/notepad-delete-everything-after-a-number-of-characters-in-string) (since you love regex.... ) – Luuk Nov 22 '21 at 12:03
  • For your sample I would use `G.*` and `Replace` leave it empty ..... – Haji Rahmatullah Nov 22 '21 at 21:04

2 Answers2

1

Another idea is to use \K which resets beginning of the reported match:

^.{4}\K.+

And replace with empty string. See this demo at regex101.

NP++ replace options: [•] regular expressions, [ ] . matches newline

bobble bubble
  • 16,888
  • 3
  • 27
  • 46
0

Use this in find/replace dialog:

Find what: (^....).*
Replace with: \1
⦿ Regular expression

Replace All

trincot
  • 317,000
  • 35
  • 244
  • 286