匹配 VMS 文件名的正确正则表达式模式是什么?
文档位于 http://h71000.www7.hp.com/ doc/731final/documentation/pdf/ovms_731_file_app.pdf (第 5-1 节)表示文件名应如下所示:
node::device:[root.][directory-name]filename.type;version
其中大多数是可选的(如节点、设备、版本) - 不确定哪些以及如何在正则表达式中正确编写此内容(包括目录名称):
DISK1:[MYROOT.][MYDIR]FILE.DAT
DISK1:[MYDIR]FILE.DAT
[MYDIR]FILE.DAT
FILE.DAT;10
NODE::DISK5:[REMOTE.ACCESS]FILE.DAT
The documentation at http://h71000.www7.hp.com/doc/731final/documentation/pdf/ovms_731_file_app.pdf (section 5-1) says the filename should look like this:
node::device:[root.][directory-name]filename.type;version
Most of them are optional (like node, device, version) - not sure which ones and how to correctly write this in a regexp, (including the directory name):
DISK1:[MYROOT.][MYDIR]FILE.DAT
DISK1:[MYDIR]FILE.DAT
[MYDIR]FILE.DAT
FILE.DAT;10
NODE::DISK5:[REMOTE.ACCESS]FILE.DAT
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅 VMS::Filespec Perl 模块的文档和源代码。
See the documentation and source for the VMS::Filespec Perl module.
从维基百科来看,完整的形式实际上比这要复杂一些:
这花了一段时间,但这里是一个应该接受所有有效变体并将组件放入捕获组的表达式。
另外,据我所知,您的示例
不是有效的名称。我相信只允许使用一对括号。我希望这有帮助!
From wikipedia, the full form is actually a bit more than that:
This one took a while, but here is an expression that should accept all valid variations, and place the components into capture groups.
Also, from what I can tell, your example of
is not a valid name. I believe only one pair of brackets are allowed. I hope this helps!
您可能会为此想出一个复杂的正则表达式,但是如果您从左到右剥离每个部分(如果存在),那么阅读代码会容易得多。以下是一些执行此操作的 Python 代码:
输出为
You could probably come up with a single complicated regex for this, but it will be much easier to read your code if you work your way from left to right stripping off each section if it is there. The following is some Python code that does just that:
and the output is