Reputation: 1849
I have the following data in my file:
234xt_
yad42_
23ft3_
45gdw_
...
Where the _
means a space.
Using Notepad++ I want to rewrite it to be:
'234xt',
'yad42',
'23ft3',
'45gdw'
I am using the following regex in the "Find what" (^\w+)\s*\n
And in the "Replace with" field $0
,
But it is not working as expected.
Upvotes: 1
Views: 79
Reputation: 626870
You may use
^(\w+) $
or
^(\w+)\h$
And replace with '$1',
.
^
will match the start of a line, (\w+)
will place one or more letters, digits or underscores into Group 1 (that you may access via $1
or \1
backreference in the replacement pattern), and then a space or \h
will match a space or any horizontal whitespace, and then $
will assert the position at the end of the line.
If the (white)spaces can go missing add the appropriate quantifier after the space or \h
: \h*
will match 0 or more whitespaces and \h?
will match 1 or 0.
Settings & demo:
Upvotes: 3