inserting ' and ', in long group of attributes
-
Hi,
may times i must insert ’ and ', in a long group of attributes, namelly a column from a sql query that i must search using operator “in” in another query…
is there any way to do this in notepad++??Example:
codea
codeb b
codec c c
…
(1 thousand codes after)
code1 2 10 20Adapt this to:
‘codea’,
‘codeb b’,
‘codec c c’,
…
(1 thousand codes after)
‘code1 2 10 20’so that finally i can do this in sql server:
select * from table1 where code in
(
‘codea’,
‘codeb b’,
‘codec c c’,
…
(1 thousand codes after)
‘code1 2 10 20’
(Thank you and regards
-
Hello @Ricardo-Magalhães-Mota-Freitas,
if this a column and you want to add a single quote in front and a single quote and a comma at the end of each line,
then we could search and replace with regular expression likefind what: ^(.+)$ replace with: '\1',^= start of the line
$ = end of the line
(.+) = match at least one char\1 = what got matched
Cheers
Claudia -
@Claudia-Frank said:
Hello @Ricardo-Magalhães-Mota-Freitas,
if this a column and you want to add a single quote in front and a single quote and a comma at the end of each line,
then we could search and replace with regular expression likefind what: ^(.+)$
replace with: ‘\1’,
^= start of the line
$ = end of the line
(.+) = match at least one char\1 = what got matched
Cheers
ClaudiaJeeesus!
Claudia thank you so much for your help :)
i think i will live more 1 month in my life with this tip… -
Glad to see that I helped to extend your life ;-D
Cheers
Claudia -
Hi, Ricardo and Claudia,
The Claudia’s regex is quite correct. however, we can, even, shorten it !
Find what : .+ Replace with : '$0',NOTES :
In the replacement field, the syntax
$nhas two interesting properties :-
The syntax
$0represents the entire searched match. So, in our example, the regex.+, that is to say, each non empty line. And the$0syntax prevents us from surrounding the searched group with the normal two round brackets ! -
Contrary to the syntax
\n( with 1<=n<=9 ), which represents the contents of the searched groups 1 to 9, the syntax$nis valid, for any group, even higher than 9 !
In the particular case, when the contents of the group n, must be followed, in replacement, with a digit, we just use the
${n}syntax, to separate the group designation, from the next digit. For instance, the following S/R, below :Find what : .+ Replace with : 00${0}00would replace any non empty line of a file by the same line, surrounded by the string 00
Cheers,
guy038
-
-
Hey, guy038,
tricky, but where does this $0 come from?
Cheers
Claudia -
Hi, Claudia,
Just look the section Placeholder Sequences, from the Boost-Extended Format String Syntax article :
http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
Regards,
guy038
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login