英文:
Poor regular expressions in Go
问题
为什么Go语言中的regexp包不支持像样的正则表达式?例如,截至Go r60.3版本,字符类\w和\s尚未实现。此外,(?:non)非捕获组也无法识别。
英文:
Why does the regexp package in Go no support decent regexp? For example the character classes \w and \s are not implemented as of Go r60.3. Also (?:non) capturing groups are not recognized.
答案1
得分: 6
使用“现有技术状态”的正则表达式包。
它支持\w
和\s
,还可以处理非捕获组(?:re)
。
英文:
Use the "current state of art" regexp package.
It has support for \w
and \s
and also handles non capturing groups (?:re)
.
答案2
得分: 1
EDIT:忽略那个:我还没有看过最近版本的正则表达式包。
如果这真的是一个问题,我想我们可以回答目前还没有人花时间构建一个完整的正则表达式库。
如果你这样做,请不要忘记考虑到现代正则表达式需要在Unicode方面正确。说到你提到的\w,那并不简单:'é'是一个单词字符。不要移植像标准JavaScript正则表达式包这样的东西。
英文:
EDIT : disregard that : I hadn't had a look at the recent versions of the regexp package
If that's really a question, I suppose we could answer that nobody for now took the time to build a complete regexp library.
If you do so, don't forget to take into account that modern regexp need to be correct regarding Unicode. Speaking of the \w you mentionned, that's not so simple : 'é' is a word character. Don't port something like the standard javascript regexp packages.
答案3
得分: 0
文档中指出“Package regexp实现了一个简单的正则表达式库”,所以我猜现在拥有一个功能完整的正则表达式库并不是当务之急。
英文:
The documentation states that 'Package regexp implements a simple regular expression library' so I guess it's not a priority at the moment to have a fully featured regex library.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论