Qt 正则表达式不匹配
Qt 的正则表达式(C++)没有按我的预期工作。例如,在以下行中(空格作为句号)
.....mRNA............complement(join(<85666..86403,86539..>86727))
“mRNA”不与以下内容匹配:
QRegExp rxItem("^\\s{5}(\\w+)") ;
但与以下内容匹配:
QRegExp rxItem("\\s{4}(\\w+)") ;
因此,看起来好像该行的开头和第一个空格由于某种原因未被识别。我查看了 QRegExp 的 Qt 文档,据我所知,“^”表示行的开头,而 \s 是 Perl 中的空格。
有什么想法吗?
干杯
Qt's regex (C++) is not working as I expect. For example, in the following line (spaces as full stops)
.....mRNA............complement(join(<85666..86403,86539..>86727))
"mRNA" is not matched by:
QRegExp rxItem("^\\s{5}(\\w+)") ;
But is matched by the following:
QRegExp rxItem("\\s{4}(\\w+)") ;
So it looks as if the start of the line and the first space is not being recognised for some reason. I checked-out the Qt documentation for QRegExp and as far as I can tell "^" signifies the start of a line and \s is space as in Perl.
Any ideas?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下代码:
显示
所以它似乎可以工作。您是否可能将
indexIn
返回的结果 0 视为错误?The following code:
displays
So it seems to be working. Did you maybe treat a result of 0 returned by
indexIn
as error?