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

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - Phoenix

Server Explorer disappeared in VS 2008 如何在外部得到一个event是否已被注册 FlashGet的堕落 画一个立体的柱图 - Phoenix - 博客园 SQL2000自动备份数据库到远程机器 Vista: user does not have administrative privileges in command prompt mode. 将一个域中的MS CRM数据库部署到另外一个域中 求救手工设置笔记本IRQ的方法 用纯API写的窗体 Windows下安装SQLPlus的帮助 Oracle Listener报“TNSLSNR.exe 应用程序错误” [导入]不使用COM组件弹出数据库连接对话框 [导入]C#: 通过动态编译获取字符串所表达的值 [导入]Asp.Net中连接Oracle [导入]全角字符的匹配 [导入]使用.Net获取OLEDB数据库的架构. [导入]使用C#在进度条中显示复制文件的进度 [导入]在SQL Server2000中修改系统表 [导入]已经毕业3个月了,怀念大学生活啊。。。
正则表达式超时
Phoenix · 2005-07-27 · via 博客园 - Phoenix

为了方便在MASM中使用,我用正则表达式从C++头文件中提取constant、function,callback等等,
在抓取这两段代码
#define NdrUnMarshConfStringHdr(p, s, l)    ((s=_midl_unma4(p,unsigned long),\
                                            (_midl_addp(p,4)),               \
                                            (l=_midl_unma4(p,unsigned long))

#define NdrMarshSCtxtHdl(pc,p,rd)   (NdrSContextMarshall((NDR_SCONTEXT)pc,p, (NDR_RUNDOWN)rd)

由于上两段代码括号并不平衡,所以在匹配时出现超时。

正则表达式由程序生成

(\#define\s+)
  (?'Name'([a-zA-Z_]\w+))
  (?'Params'(\([^\(\)\#]*\)))?
   \s+
  ((0(x|X)[0-9a-fA-F]+)|
  (\d+)|
  ([a-zA-Z_]\w+)|
  ("(?>[^"]+|"")*")|
  (\(([^\(\)\#]+|
  (?'Paren'\()|(?'Close-Paren'\)))*?(?(Paren)(?!))\))|
  (\+|\-|\*|/\\)|
  (([a-zA-Z_]\w+)(\(([^\(\)\#]+|(?'Paren'\()|(?'Close-Paren'\)))*?(?(Paren)(?!))\))))?

简化为这两种情况之后还是出现超时
(\#define\s+)
 (?'Name'([a-zA-Z_]\w+))
  (?'Params'(\([^\(\)\#]*\)))?
   \s+
  (\(([^\(\)\#]+|(?'Paren'\()|(?'Close-Paren'\)))*?(?(Paren)(?!))\))

(\#define\s+)
   (?'Name'([a-zA-Z_]\w+))
     (.+?)
     (\(([^\(\)\#]+|(?'Paren'\()|(?'Close-Paren'\)))*?(?(Paren)(?!))\))

一些匹配和文本导致超时的情况

^[a-zA-Z0-9]+((.?|\-*)[a-zA-Z0-9]+)*$
asdf.host-name.asd-f.

^(([a-zA-Z\d!#$%&'*+-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?
((?!\.)(\.?[a-zA-Z\d!#$%&'*+-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")
@
(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}
|\[
(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}
|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)
\])
(?(angle)>)$
www42af43ds.afsd.fds.ds

^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$
hello23423423423424n@aol.c