用其他文本包围 2 列或多列文本
我正在调试一些 ColdFusion 代码(尽管问题实际上与语言无关),并且从调试输出中,有两列文本。
这些列是字段名称
值,并且希望能够快速将其转换为测试代码。
我开始的文本:
a 1
b 2
c 3
etc
我想要结束的代码:
structInsert(myStruct, "a", 1);
structInsert(myStruct, "b", 2);
structInsert(myStruct, "c", 3);
etc
通常,我会使用 Excel,将两列数据粘贴到 A 列和 B 列中,并在 C 列中创建一个公式,将 A 和 B 连接起来,就像
="structInsert(myStruct, """ & A1 & """, " & B1 & ");"
这样效果很好(这也是我喜欢 Excel 的主要原因之一)。
但我想知道……既然全世界都没有 Excel,那么其他人是如何做到这一点的呢?
谢谢!
I'm debugging some ColdFusion code (although the question is really language-agnostic), and from the debug output, have two columns of text.
Those columns are field name <tab>
value and want to be able to quickly convert this into test code.
The text I start off with:
a 1
b 2
c 3
etc
The code I want to end up with:
structInsert(myStruct, "a", 1);
structInsert(myStruct, "b", 2);
structInsert(myStruct, "c", 3);
etc
Ordinarily, I'd use Excel, pasting the two columns of data into columns A and B, and create a formula in column C that concatenates A and B something like
="structInsert(myStruct, """ & A1 & """, " & B1 & ");"
This works fine (and is one of the main reasons I love Excel).
But I'm wondering... given that the whole world doesn't have Excel, how does everyone else do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我喜欢使用 Notepad++ 或 Eclipse 进行搜索,并使用正则表达式替换功能。
喜欢搜索
([az]*)\t(\d)
替换为
structInsert(myStruct,"\1",\2);
这么简单..对吧?
Well I like to do with Notepad++ or Eclipse with search and replace feature with regular expression.
Like search for
([a-z]*)\t(\d)
replace with
structInsert(myStruct,"\1",\2);
So simple.. right?
您可以使用正则表达式来做到这一点。
在 CFEclipse/CFBuilder 中打开查找/替换对话框
查找:^(.+?)\t(.+?)$
替换为:structInsert(myStruct, "$1", $2);
检查正则表达式
单击全部替换
You could do this with regular expressions.
In CFEclipse/CFBuilder open the Find/Replace dialogue
Find: ^(.+?)\t(.+?)$
Replace with: structInsert(myStruct, "$1", $2);
Check Regular Expressions
Click Replace All