惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
Security Latest
Security Latest
G
GRAHAM CLULEY
C
CXSECURITY Database RSS Feed - CXSecurity.com
云风的 BLOG
云风的 BLOG
月光博客
月光博客
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
Attack and Defense Labs
Attack and Defense Labs
罗磊的独立博客
D
DataBreaches.Net
TaoSecurity Blog
TaoSecurity Blog
T
Threatpost
S
Secure Thoughts
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
Cisco Talos Blog
Cisco Talos Blog
Google Online Security Blog
Google Online Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
NISL@THU
NISL@THU
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
PCI Perspectives
PCI Perspectives
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
V
V2EX
WordPress大学
WordPress大学
Recorded Future
Recorded Future
Stack Overflow Blog
Stack Overflow Blog
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
D
Docker
Latest news
Latest news
C
CERT Recently Published Vulnerability Notes
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
V2EX - 技术
V2EX - 技术
小众软件
小众软件
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

正则表达式

增加一点动力学正则 - V2EX 求教,如何系统性的学习正则表达式? - V2EX sigil 正则表达式疑问 - V2EX editplus 中如何去掉空格 - V2EX 临门一脚,这个正则怎么匹配不上字符串啊? - V2EX 正则表达式合集帖(希望本帖能存活十年以上) - V2EX 正则如何完整匹配整个单词 - V2EX 请问 EM 正则如何在文章最前面添加一段话 - V2EX 求教,这个正则怎么写 - V2EX /(\w*)*$/.test('aaa#')这个正则导致我们的页面炸了……不同语言居然不一样 - V2EX 这个可以用正则表达式做到吗?GPT 聊了半天了 - V2EX [求助]如何利用正则表达式将文本或换行用 p 标签包裹起来 - V2EX 正则匹配,怎么匹配不定内容的成对的中间的内容呢? - V2EX 正则表达式 locate --regex 'bin/(bz|gz|zip)'有没语法问题? - V2EX 上下两行内容合并正则有办法能实现吗 - V2EX 正则表达式如何截取一个完整括号的内容 - V2EX 有对 posix-正则 有研究的吗?问下 - V2EX editplus 求个全选正则忽略前面的符号及符号内的内容 - V2EX 各位老哥,正则怎么写能排除一个或多个特定的 IP,匹配剩余所有 IP(或者说是否可以实现) - V2EX 使用正则.*ab.*搜索二进制文件(pdf 格式),搜不到 ab 但是.*a.*可以找到 a,除了 ab 还有别的正则写法么? - V2EX 这个正则表达式怎么写,要么在开头,要么前面有空格 - V2EX 求助:正则获取 sql 语句中的表名 - V2EX Safari 上不支持向后匹配的正则表达式,请教替代方法 - V2EX 正则表达式如何忽略子字符串中的内容 - V2EX 求助 nginx 的 rewrite,需求是把 http 流量转到 https - V2EX 求大佬指点 - V2EX iHateRegex 一个收录各种正则表达式的网站 - V2EX 请教一下,如何利用正则表达将 html 中在<p></p>之间的/筛选出来 - V2EX ep 求一个数字和单位的正则 - V2EX 正则菜鸟求教 - V2EX 正则 backtrack 请教 - V2EX 求给生成一个正则表达式,年龄大了,脑子不够用了 - V2EX 请问正则这种替换该怎么填 - V2EX 求个表格补 0 的正则表达式。 - V2EX 求个正则? pathname/{id}/sub_pathname - V2EX [求助] 请问正则从后往前非贪婪匹配 - V2EX [求助]正则表达式的正向否定预查,无法筛选某些字符串 - V2EX 全书很多空格,求一个正则表达式帮我看看是否行的通? - V2EX 请问正则表达式中,中间部分的?:的作用是什么? - V2EX 关于正则数字添加千分号 /\B((?=(?:\d{3}))+$)/g 不太理解 - V2EX 请问提取 caseId 的数字正则怎么写? - V2EX 求个正则 - V2EX JS 里面的 string.match,怎么把匹配字符串取出来? - V2EX 求大佬指点 js 正则,拜谢 - V2EX 求问:正则对位置匹配是怎么处理的? 正则表达式如何嵌套匹配 - V2EX 我请教一个 Python 正则表达式问题 - V2EX 提问一个正则匹配的问题 - V2EX
想请教一个正则表达式,这正则能做吗 - V2EX
f9EHtxE2UtX3fG3 · 2023-02-10 · via 正则表达式

背景

  • 想要一块代码中抽取出 函数返回值, 函数名 函数类型,用来编出 main 函数

想要的功能,这能用正则做吗?

  • 可以匹配 c++函数的 返回值类型、函数名、参数类型列表
  • 返回值类型、参数类型会有:
    • 类型 1:
      • int
      • char
      • string
      • TreeNode *
      • Node *
    • vector<类型 1>
    • vector<类型 1> &
    • vector<vector<类型 1>>
    • vector<vector<类型 1>> &

问了 OpenAI 感觉不太对,每次问结果都不一样

Here's a regular expression that matches the return value type, function name, and parameter type in C++:

(int|vector<int>|vector<vector<int>>|string|vector<string>|vector<vector<string>>|ListNode\*|vector<ListNode\*>|char|vector<char>|vector<vector<char>>|TreeNode\*|Node\*)\s(\w+)\((.*)\)
The regular expression uses the following components:

(int|vector<int>|vector<vector<int>>|string|vector<string>|vector<vector<string>>|ListNode\*|vector<ListNode\*>|char|vector<char>|vector<vector<char>>|TreeNode\*|Node\*) matches the return value type, which can be one of the specified types.

\s matches a whitespace character.

(\w+) matches the function name, which is one or more word characters.

\(.*\) matches the parameter list, which is zero or more characters enclosed in parentheses.

举个例子

vector<int> f(vector<int>& a, TreeNode *b, int d){

}

  • 提取类型为了初始化
    vector<int> arg1 = {};
    TreeNode * arg2 = new TreeNode(xxx);
    int arg3 = 0;
    vector<int> result = f(arg1, arg2, arg3);

如果不能做,那只能写代码硬匹配了?