RegEx string to find two strings and delete the rest of the text in the file

前端 未结 2 1289
滥情空心
滥情空心 2021-01-24 11:51

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

2条回答
  •  走了就别回头了
    2021-01-24 12:07

    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 pattern

提交回复
热议问题