regex - Remove all spaces from lines starting with specific word -
using regex find/replace in notepadd++ how can remove spaces line if line starts 'chapter'?
example text:
chapter b c once upon time. what want end with:
chapterabc once upon time. incorrect code like:
(?<=chapter)( )(?<=\r\n) so 'chapter' needs stay , search should stop @ first line break.
you may use \g based regex match line starts chapter , match consecutive non-whitespace , whitespace chunks linebreak while omitting matched non-whitespace chunks , removing horizontal whitespace:
(?:^chapter|(?!^)\g)\s*\k\h+ details:
(?:^chapter|(?!^)\g)-chapter@ start of line (^chapter) or (|) end of previous successful match ((?!^)\g,\gcan match start of line, use retricting negative lookahead.)\s*- 0 or more non-whitespace symbols\k- match reset operator forcing regex engine omit text matched far (thus, not removechapteror of non-whitespace chunks)\h+- horizontal whitespace (1 or more occurrences) only

Comments
Post a Comment