在自定义批处理语法中用作分隔符的最佳字符是什么?
我编写了一个小程序来将图像从网络下载到不同的文件夹。 我想创建一个快速而肮脏的批处理文件语法,并且想知道不同变量的最佳分隔符是什么。
这些变量可能包括 url、文件夹路径、文件名和一些自定义消息。
那么有哪些字符不能用于前三个呢? 这将是用作分隔符的明显选择。 那个好的老逗号怎么样?
谢谢!
I've written a little program to download images to different folders from the web. I want to create a quick and dirty batch file syntax and was wondering what the best delimiter would be for the different variables.
The variables might include urls, folder paths, filenames and some custom messages.
So are there any characters that cannot be used for the first three? That would be the obvious choice to use as a delimiter. How about the good old comma?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以使用:
#s#
等。Tab 通常是首选。
You can use either:
#s#
etc.Tab is the generally preferred choice though.
为什么不直接使用已经存在的东西呢? 有一两个选择,perl、python、ruby、bash、sh、csh、Groovy、ECMAscript,天哪,禁止 Windows 脚本文件。
我看不出编写另一个批处理文件语法会带来什么好处。
Why not just use something that exists already? There are one or two choices, perl, python, ruby, bash, sh, csh, Groovy, ECMAscript, heavens for forbid windows scripting files.
I can't see what you'd gain by writing yet another batch file syntax.
选项卡。 然后展开或压缩文本中找到的任何选项卡。
Tabs. And then expand or compress any tabs found in the text.
选择与您可能拥有的任何变量名称发生冲突的可能性最小的分隔符(排除
#
、/
、:
等)。 逗号 (,
) 对我来说看起来不错(除非您的自定义消息有一些)或<
和>
(取决于之前的条件)。但是,您可能还需要“转义”作为要分隔的变量的一部分出现的分隔符。
Choose a delimiter that has the least chance of collision with the names of any variable that you may have (which precludes
#
,/
,:
etc). The comma (,
) looks good to me (unless your custom message has a few) or<
and>
(subject to previous condition).However, you may also need to 'escape' delimiter characters occurring as part of the variables you want to delimit.
这听起来真是个糟糕的主意。 无需创建另一种(数据表示)语言,有很多语言可能适合您的需求。 除了 Ruby、Perl 等之外,您可能还需要考虑 YAML。
为此类设计良好的语法非常困难且充满危险。 重新发明轮子是否敲响了警钟?
This sounds like a really bad idea. There is no need to create yet another (data-representation) language, there are plenty ones which might fit your needs. In addition to Ruby, Perl, etc., you may want to consider YAML.
Designing good syntax for these sort of this is difficult and fraught with peril. Does reinventing the wheel ring a bell?
我会使用“|”
这是最稀有的角色之一。
I would use '|'
It's one of the rarest characters.
String.fromCharCode(1)
怎么样?How about
String.fromCharCode(1)
?