I need to do a find and delete the rest in a text file with notepad+++ i want tu use RegeX to find variations on thban..... the variable always has max 5 chars behind it(see dot
You may use
Find What: (?|\b(thban\S{0,5})|\s(C3\w+))|(?s:.)
Replace With: (?1$1\n:)
Screenshot & settings
Details
(?| - start of a branch reset group:
\b(thban\S{0,5}) - Group 1: a word boundary, then thban and any 0 to 5 non-whitespace chars| - or\s(C3\w+) - a whitespace char, and then Group 1: C3 and one or more word chars) - end of the branch reset group| - or(?s:.) - any one char (including line break chars)The replacement is
(?1 - if Group 1 matched,
$1\n - Group 1 value with a newline: - else, replace with empty string) - end of the conditional replacement patternMaybe just capture those words of interest instead of replacing everything else? In Notepad++ search for pattern:
^.*\b(thban\S{0,5})(?:.*(\sC3\w+))?.*$|.+
See the Online Demo
^ - Start string ancor..*\b - Any character other than newline zero or more times upto a word-boundary.(- Open 1st capture group.
thban\S{0,5} - Match "thban" and zero or 5 non-whitespace chars.) - Close 1st capture group.(?: - Open non-capturing group.
.* - Any character other than newline zero or more times.( - Open 2nd capture group.
\sC3\w+ - A whitespace character, match "C3" and one ore more word characters.) - Close 2nd capture group.)? - Close non-capturing group and make it optional..* - Any character other than newline zero or more times.$ - End string ancor.| - Alternation (OR)..+ - Any character other than newline once or more.Replace with:
$1$2
After this, you may end up with empty line you can switly remove using the build-in option. I'm unaware of the english terms so I made a GIF to show you where to find these buttons:
I'm not sure what the english checkbutton is for ignore case. But make sure that is not ticked.