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

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

问题描述

我想使用正则表达式解析器中一些字符串处理,以帮助在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的,一个开源的文本编辑器组件,使用<一个HREF =htt​​p://www.cs.yorku.ca/~oz/> Ozan S. Yigit的RE引擎

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

选择它是因为它是在公共领域(所以没有拖累许可证),非常轻巧。但实在是有点......有限的它是什么价值,<一个href=\"http://scintilla.cvs.sourceforge.net/viewvc/scintilla/scintilla/src/RESearch.cxx?revision=1.19&view=markup\">RESearch.cxx使用一个稍微更现代的code(转换为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.).

有一些选择,如 Henry Spencer的前定期pression库的。

试想想起来了,的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 可以是一个有趣的替代资源,还是轻巧但功能强大。

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

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

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