Ada 中的正则表达式?
我对 Ada 很陌生,我正在尝试用一些文本做一些简单的工作。我想要做的就是读入一个文件,并删除除字母、空格或换行符之外的所有内容。所以删除所有标点符号和数字。在其他语言中,我只会创建一个简单的 [^a-zA-Z] 正则表达式,查看每个字符,如果它适合 RegEx,则将其删除,但我似乎无法在 Ada 中找到有关 RegEx 的任何文档。那么,Ada 中有 RegEx 吗?如果没有,那么对我来说进行这样的简单文本编辑的最佳方法是什么。
非常感谢, -jb
I'm very new to Ada, and I'm trying to do some simple work with some text. All I want to do is read in a file, and strip out anything that isn't a letter, space, or new line. so removing all the punctuation and numbers. In other languages I would just create a simple [^a-zA-Z] regular expression, look at each character and delete it if it fit the RegEx, but I can't seem to find any documentation on RegEx's in Ada. So, are there RegEx's in Ada? If not, what's the best way for me to go about simple text editing like this.
thanks much,
-jb
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用 GNAT 编译器,则有一组名为
GNAT.RegExp
、GNAT.RegPat
和GNAT.Spitbol
的软件包专门用于此目的任务。请注意,它不是标准的 ala perl 正则表达式,而是基于 SNOBOL4。但是,从一种类型的正则表达式转换为另一种类型应该不会很困难。
if you are using the GNAT compiler, there are a set of packages called
GNAT.RegExp
,GNAT.RegPat
andGNAT.Spitbol
made for this task.beware that it is not standard regexp ala perl but is based on SNOBOL4. however, it should not be very difficult to convert from one type of regular expression to another.
您可能想查看这个示例,只查找要忽略的字符,而不是将它们放入新字符串中。
您使用的是哪个版本的 Ada?
http://www.adaic.com/docs/ 95style/html/sec_8/8-4-7.html
You may want to go through this example, and just look for the characters you want to ignore and don't put them into the new string.
Which version of Ada are you using?
http://www.adaic.com/docs/95style/html/sec_8/8-4-7.html
我可能会看看你鞋子里的 Gnat snobol 东西。
然而,有一个可用于一般词法分析的项目(有点像 Boot's Spirit),名为 OpenToken< /a>.对于稍微复杂的任务,您可能会发现它很有用。
我还没有使用过现代版本,但当我领导该项目时,该项目与编译器无关。
I'd probably look at the Gnat snobol stuff in your shoes.
However, there is a project available for general lexical analysis (somewhat like Boot's Spirit) called OpenToken. For slighly more complex tasks, you may find it useful.
I haven't worked with the modern incarnation, but back when I was the lead on it the project was compiler-agnostic.