2017-02-25 13:01
浏览 207


The regexp in the Go's standard library is quite poor, so I need a more powerful engine, like regex in Python (pip install regex), supporting recursion, backref, look-ahead/behind, etc... .

I found: .NET compatible, which was quite fine; however, recursion is not working properly.

and several bindings to PCRE, for example:

so, how can I use this binding on Win64?

图片转代码服务由CSDN问答提供 功能建议

Go的标准库中的 regexp 很差,所以我需要一个功能更强大的 引擎,例如Python中的正则表达式(pip install regex),支持递归,后向引用,前瞻/后退等。...

我发现: .NET兼容, 精细; 但是,递归无法正常工作。

以及与PCRE的多个绑定,例如: ”>


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dora12345678 2017-02-25 14:30

    You may consider using C++ standard library std::regex (no third-party library). Wrap the logic in try block, use catch(...){return ERROR;} to catch any error, and declare the C function extern "C" so you can call with cgo.

    From (there is a part about Windows):

    In order to use cgo on Windows, you'll also need to first install a gcc compiler (for instance, mingw-w64) and have gcc.exe (etc.) in your PATH environment variable before compiling with cgo will work.

    That being said, I still think you should consider sticking with the regexp package and try to make regular expressions as simple as possible. Because complicated regular expressions are likely to hurt readability of code. Another problem is sometimes they introduce subtle bugs which are difficult to spot and fix. So writing more code in Go instead of regex may actually make the life easier.

    点赞 打赏 评论

相关推荐 更多相似问题