1

I'm trying to remove all characters except those sandwiched between 2 strings,

my original text:

BlahBlahBlahBlahBlahbeginningMY,IMPORTANT,text,1endblahblahblahblblah
XXXXXXXXXXXXXXXXXXXXbeginningMY,IMPORTANT,text,2endblahb2XXXXXXXXXXXX
YYYYYYYYYYYYYYYYYYYYbeginningMY,IMPORTANT,text,3endYYYYYYYYYYYY
UUUUUUUUUUUUUUUUUUUUbeginningMY,IMPORTANT,text,4endUVUVUVUVUVUVUVUVUV

The desire output:

beginningMY,IMPORTANT,text,1end
beginningMY,IMPORTANT,text,2end
beginningMY,IMPORTANT,text,3end
beginningMY,IMPORTANT,text,4end

I used this

beginning(.*)end

RegEx in regexr.com and got a useful list like this

enter image description here

I'm not allowed to upload my data to any website so how can I do this On Notepad++ ?

enter image description here

bobble bubble
  • 16,888
  • 3
  • 27
  • 46
  • `(beginning.*end)|.` => `(?{1}$1\n:)` – Wiktor Stribiżew Oct 05 '22 at 05:50
  • 1
    Another idea: Search for [`(?s).*?(beginning.*?end)|.+` and replace with `$1`](https://regex101.com/r/Uh2KAW/1) – bobble bubble Oct 05 '22 at 08:30
  • Further have a look at [`(*SKIP)(*F)`](https://stackoverflow.com/questions/24534782/how-do-skip-or-f-work-on-regex) which is useful for skipping certain parts but match others. It is often used in combination with variations of [the trick](https://www.rexegg.com/regex-best-trick.html#thetrick). For your input e.g. search for [`beginning.*?end(*SKIP)(*F)|.` and replace with empty](https://regex101.com/r/H9CJ4M/1). – bobble bubble Oct 05 '22 at 09:04

0 Answers0