轻量级正则表达式解析器 [英] Lightweight regex parser

查看:567
本文介绍了轻量级正则表达式解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用正则表达式解析器来帮助C应用程序中的某些字符串处理。我理想地寻找轻量级和开源的东西。目标平台是嵌入式系统,所以我们希望尽可能地节省内存消耗。我已经在网上找到了一些选项,但是想知道是否有人可以提出可能有助于这个特定环境的其他建议。

I'd like to use a Regex parser to aid in some string processing in a C application. I'm ideally looking for something lightweight and open-source. The target platform is an embedded system so we're looking to save as much as possible with memory consumption in particular. I've found a number of options online but was wondering if anyone can make additional suggestions that may help in this particular context.

非常感谢,

推荐答案

Scintilla ,一个开源的文本编辑器组件,使用 Ozan S. Yigit的RE引擎

Scintilla, an open source text editor component, uses Ozan S. Yigit's RE engine

被选中是因为它在公共领域(所以没有密码许可证),非常轻量级。但是它有点有限...为什么值得, RESearch.cxx 使用稍微更现代的代码(转换为C ++,但不应该很复杂,可以将其转换回C),并使用一些小的扩展名我自己(支持\d \s \w等)。

It was chosen because it is in the public domain (so no encumbering license) and very lightweight. But it is a bit limited... For what it is worth, RESearch.cxx uses a slightly more modern code (converted to C++ but it shouldn't be complex to convert it back to C) with some minor extensions made by myself (support of \d \s \w etc.).

有一些替代方案,如亨利·斯潘塞的正则表达式库

来想想, Lua 正则表达式引擎(在字符串库中,gsub实现等等)也可能很快也很小语言本身。它有它的怪癖和限制,但它是非常有用的。

Come to think of it, the Lua regex engine (in string library, gsub implementation among others) is probably fast and small too, like the language itself. It has its quirks and limitations, but it is very usable.

侧面的项目 LPeg 可以是一个有趣的替代RE,仍然轻量级而强大。

The side project LPeg can be an interesting alternative to REs, still lightweight yet powerful.

这篇关于轻量级正则表达式解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆