How To Join with comma ONLY Lines Starting with Indent (Tab or 4 space) at Notepad++

How can I join with comma ONLY all lines that has indent (Tab or 4 space) at beginning in NotePad++

analyse
    analysed
    analyser
    analysers
    analyses
    analysing
    analysis
    analyst
    analysts
    analytic
    analytical
approach
    approachable
    approached
    approaches
    approaching
    unapproachable

to be like

analyse
'analysed','analyser','analysers','analyses','analysing','analysis','analyst','analysts','analytic','analytical'
approach
'approachable','approached','approaches','approaching','unapproachable'

Solution 1:

  • Ctrl+H
  • Find what: \h+(\w+)(\R?)(\w)?
  • Replace with: '$1'(?3$2:,)$3
  • CHECK Wrap around
  • CHECK Regular expression
  • Replace all

Explanation:

\h+         # 1 or more horizontal spaces
(\w+)       # group 1, 1 or more word characters
(\R?)       # group 2, any kind of linebreak, optionnal
(\w)?       # group 3, optionnal, a word character

Replacement:

'               # single quote
$1              # content of group 1
'               # single quote
(?3             # if group 3 exists (i.e. there is a word chracter at the beginning of next line)
    $2              # add content of group 2, the linebreak
  :               # else
    ,               # add a comma
)               # endif
$3              # content of group 3

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here