- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在http://llvm.org/svn/llvm-project/libcxx/trunk/test/re/re.alg/re.alg.match/ecma.pass.cpp ,存在以下测试:
std::cmatch m;
const char s[] = "tournament";
assert(!std::regex_match(s, m, std::regex("tour|to|tournament")));
assert(m.size() == 0);
为什么这个匹配会失败?
在VC++2012和boost上,匹配成功。
在 Chrome 和 Firefox 的 Javascript 上,"tournament".match(/^(?:tour|to|tournament)$/)
成功。
仅在 libc++ 上,匹配失败。
最佳答案
我相信测试是正确的。在 re.alg 下的所有 libc++ 测试中搜索“tournament”并比较不同引擎如何处理 regex("tour|to|tournament")
是有益的。 ,以及如何regex_search
不同于 regex_match
.
让我们从regex_search
开始:
awk,egrep,扩展:
regex_search("tournament", m, regex("tour|to|tournament"))
matches the entire input string: "tournament".
ECMAScript:
regex_search("tournament", m, regex("tour|to|tournament"))
matches only part of the input string: "tour".
grep,基本的:
regex_search("tournament", m, regex("tour|to|tournament"))
Doesn't match at all. The '|' character is not special.
awk、egrep 和 extended 将尽可能多地匹配交替。然而,ECMAScript 交替是“有序的”。这在 ECMA-262 中指定.一旦 ECMAScript 匹配了交替中的一个分支,它就会退出搜索。该标准包括这个例子:
/a|ab/.exec("abc")
returns the result "a" and not "ab".
<plug>
这也在 Mastering Regular Expressions by Jeffrey E.F. Friedl 中进行了深入讨论。 .我无法实现 <regex>
没有这本书。我坦率地承认,关于正则表达式,我不知道的比我知道的要多得多。
在交替章节的结尾,作者指出:
If you understood everything in this chapter the first time you read it, you probably didn't read it in the first place.
相信吧!
</plug>
无论如何,ECMAScript 只匹配“tour”。 regex_match
仅当匹配整个 输入字符串时,算法才会返回成功。由于仅匹配输入字符串的前 4 个字符,因此与 awk、egrep 和扩展不同,ECMAScript 返回 false 并返回大小为零的 cmatch
。 .
关于c++ - 在 libc++ 上,为什么 regex_match ("tournament", regex ("tour|to|tournament")) 失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17609325/
go版本go1.12.9 darwin/amd64 安装 golang.org/x/tour 软件包后,我运行命令 tour 并收到错误: Couldn't find tour files: coul
使用 bootstrap-tour 插件 ( http://bootstraptour.com/ ),我想在除最后一步之外的每个步骤上禁用或隐藏默认的“End Tour”按钮。 我尝试修改步骤模板以完
我正在尝试使用 Bootstrap 主题在 Wordpress 网站上实现 Bootstrap Tour,但到目前为止,每次我尝试链接样式表 (CSS) 和 JavaScrit 时,它都不起作用。该页
正如“A Tour of Go”的 Crawl 示例中提到的命中,我修改了 Crawl 函数,只是想知道为什么“go Crawl”无法生成另一个线程,因为只找到一个 url 被打印出来。 我的修改有问
HTML: button JS: var tour = new Tour({ steps: [{ element: "#enrol-btn1", title: "Exam Enrolm
我正在尝试使用 vue-tour,按照指南中的确切步骤我收到了这个错误 https://github.com/pulsardev/vue-tour 步骤 在 main.js 上添加 vue-tour
我正在尝试使用DFS制作程序骑士之旅,但我无法解决这个程序..因为我总是有这样的消息错误 线程“AWT-EventQueue-0”中的异常java.lang.ArrayIndexOutOfBounds
我真的可以使用帮助来关闭我正在构建的网页的 Bootstrap Tour 插件的“自动启动”功能。这次旅行本身效果很好。它按照预期从一步跳到另一步。但是,当用户第一次查看页面时,导览会自行开始。用户可
我正在使用 Bootstrap 游览,但问题是我只需要游览/突出显示不正确的字段。 Bootstrap 游览的问题在于硬编码所有元素 id 或类名。我遇到的表单错误是基于不正确的字段。因此,我无法对字
我们可以通过获取当前步骤元素 var step = tour._options.steps[tour.getCurrentStep()]; var element=$(step.element); 与
我一直在尝试使用“Bootstrap Tour”在我的网站上安装一个导览,我对 Javascript 和一般编码还很陌生,而且我已经做了一整天。我想我会来这里问更有经验的人。 hi1 有时会起作用,但
我对 Bootstrap tour 有疑问. 我的问题 当我从一个页面重定向到另一个页面时,init 函数将被调用,但不会自动继续浏览。所以 Bootstrap 之旅不会显示。该页面还包含一个 AJA
我在这里发帖是因为我无法在 Boostrap Tour 的官方文档或此处的任何其他主题中找到解决我的问题的方法。 这是我的问题:我有一个页面,我想在其中初始化两个游览,以便让我的用户选择从哪一个开始。
我通过我的网站进行了游览。我希望用户在结束游览后可以通过单击按钮手动开始游览。 按钮: Start Tour Bootstrap 游览脚本。 var tour = new Tour(); tour
我正在尝试突出显示表格行。即使有了针对 z-indexes 等的 Bootstrap 修复 github issue link 看看这个 fiddle :jsFiddle JavaScript $("
我在我的网站“Drupal 8”上安装了下一个模块“D8:Bootstrap Tour”,它使用主题“Bootstrap 3”。 https://www.drupal.org/project/bs_t
以下是我的引用代码: 我正在为我的应用程序使用 Bootstrap 游览。 要求: 当我点击“下一步”时,我处于第一步,然后它正在检查“#id2”的值。如果 id2 值不为空,则应跳过该步骤并直接进入
我已经在我的项目中实现了 Bootstrap 之旅。我尝试将其加载到模态窗口上,但没有显示任何内容。下面是我的代码: $(document).ready(function (
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 8 年前。
我正在玩 Bootstrap Tour,我发现自己卡在了导航页面上。 在我的导览中,第四步将用户从 index.cshtml 带到 page.cshtml,这工作正常,但是导览框不会在 page.cs
我是一名优秀的程序员,十分优秀!