如何在Notepad++中用正则表达式给逗号分隔字符串加单引号?
Wrapping CSV Headers with Single Quotes in Notepad++
Hey there! Since you’ve already got the regex [a-zA-Z]* set up to match each header word in Notepad++, the replacement string you need is simple:
'$0'
Why this works:
$0is a regex backreference that stands for the full text your pattern matched (each individual header likeType,Layer, etc.).- By wrapping
$0in single quotes, you’re telling Notepad++ to take every matched word and surround it with'—exactly the output you’re aiming for.
Quick heads-up:
Your current regex [a-zA-Z]* works great for headers made only of letters (like performedBy), but if you ever have headers with numbers or underscores, you could switch to [\w]* instead to match all word characters. But for your specific case, your existing regex paired with '$0' will do the trick perfectly.
Just double-check that the "Regular expression" option is selected in the Replace dialog, hit "Replace All", and you’ll have your formatted headers in no time!
内容的提问来源于stack exchange,提问作者Neha Vari
相关产品推荐
相关产品推荐

