需要对csv文件的每个值应用双引号
我有一个csv文件,我需要每一列包装在引号中。如何使用regex更改它?
I have a csv file that I need EVERY column wrapped in quotes. How do I change that using regex?
我使用我的文本编辑器来执行find / replace w /正则表达式(textmate)
I am using my text editor to do the find/replace w/ regular expression (textmate)
example csv:
example csv:
bear,brown,mean,large
ant,black,strong,tiny
cat,yellow,moody,small
p>这里是正则表达式的重要部分。希望当我转换为textmate格式时,我得到它:
Here are the important portions of the regex. Hopefully I got it right when I converted to textmate format:
搜索 - ([^,] *)(,| $)
替换 - $ 1$ 2
搜索说明:查找不是逗号的每个字符,直到到达逗号或行尾。捕获要在一个变量中引用的字符串的匹配,并在另一个变量中捕获逗号/行尾匹配。
Search explanation: Find every character that is not a comma, up until we reach a comma, or the end of the line. Capture the match for string to be quoted in one variable, and capture the comma/end-of-line match in another variable.
替换解释:引用的原始字符串,以及其后的逗号或行尾。
Replace explanation: The original string, quoted, and the comma or end-of-line that follows it.