boost::正则表达式和波形符 (~)

发布于 2024-09-29 02:13:55 字数 482 浏览 1 评论 0原文

请您解释一下为什么给出以下 boost::regex 模式:

boost::regex re("/\\S+\\w");

/index.html 匹配而 /~index.html 不匹配? Perl 模式下的 RegexBuddy 在这两种情况下都会找到匹配项。

您能建议一种可行的模式吗?谢谢!!

PS 末尾需要有 \\w,以便忽略 /index.html. 等 URL 末尾的标点符号。

UPD:抱歉,我只是尝试制作一个简单的测试程序,并且它可以正常工作。我猜问题可能出在调用 regex_search 的代码中。我需要更多时间来找出这个问题。

UPD2:确实问题出在我的代码中。请投票以结束问题。抱歉,在发布之前没有进行足够的研究。

Please could you explain why given the following boost::regex pattern:

boost::regex re("/\\S+\\w");

/index.html is a match and /~index.html is not?
RegexBuddy in Perl mode finds a match in both cases.

Could you suggest a pattern that would work? Thanks!!

P.S. The \\w at the end is needed in order to ignore the punctuation on the end of an URL like /index.html..

UPD: Sorry just tried to make a simple test program and it works there. I guess the problem might be in the code that calls regex_search. I need a bit more time to find this out.

UPD2: Indeed the problem was in my code. Please vote to close the question. Sorry for not researching enough before posting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文