gpt4 book ai didi

ios - 这个正则表达式会检测到什么?

转载 作者:行者123 更新时间:2023-11-29 02:36:37 25 4
gpt4 key购买 nike

我不是 Regex 字符串方面最伟大的专家,所以我不知道这个人应该在这里找到什么:

@"\\[(.*?)\\]\\((\\S+)(\\s+(\"|\')(.*?)(\"|\'))?\\)"

我正在尝试为应用程序获取 Markdown 模式。任何人都可以帮助我了解这应该找到哪些模式集?

最佳答案

正则表达式似乎与超链接的 Markdown 格式匹配。特别是那些直接指定链接而不使用引用样式的。

[linked text](http://www.example.com/hyperlink "optional tooltip")

捕获组 1 包含链接文本。
捕获组 2 包含超链接。
捕获组 4 包含可选的工具提示。

下面是这个问题的示例超链接,一个有工具提示,另一个没有工具提示:

以上2个超链接的来源:

- [What will this regular expression detect?](https://stackoverflow.com/questions/26285433/what-will-this-regular-expression-detect "What will this regular expression detect?") (try hovering your mouse over this one)
- [What will this regular expression detect?](https://stackoverflow.com/questions/26285433/what-will-this-regular-expression-detect)

您可以尝试将上面的示例文本与您的正则表达式匹配。一旦你看到结果,它就会变得清晰。这是 demo on regex101 .

(我写了\[(.*?)\]\((\S+)(\s+("|')(.*?)("|'))?\)在上面的演示中,因为它是正则表达式引擎看到的)

关于ios - 这个正则表达式会检测到什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26285433/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com