简体   繁体   中英

Regex using notepad++ to delete and replace text

I'm trying to use regex to replace and delete some text on existing code.

Here is sample of my text

01;TEST;Delete;Delete;Delete;keep||

So far I was able to replace the number and test to new text using ^\\d+\\; but I would like to delete 3 texts after words and keep the 4th.

You can try this regex in Find what:

^(\d+);([^;]+);[^;]+;[^;]+;[^;]+;(.*)$

And this expression in Replace with: \\1\\2\\3

Here \\1 will capture a number, \\2 - a text next to it (TEST in your example), \\3 - anything after the last "Delete". You can put any other text instead of \\2 or \\3 , of course.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM