paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Why aren’t regular expressions a lingua franca? an empirical study on the re-use and portability of regular expressions

为什么正则表达式不是通用语言?关于正则表达式复用与可移植性的实证研究
FSE Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering2019匹配度 3/10 · 该论文是正则表达式跨语言可移植性的实证研究,属于语言语义与软件工程范畴,与用户核心方向(静态分析×LLM/Agent、浮点程序分析、贝叶斯程序分析)没有直接交集;仅在构建大规模语料(53万条 regex)并揭示跨引擎语义/性能差异这类问题上,与用户对 benchmark 与问题驱动型研究的偏好有微弱重合。引用 51 inbox
James C. Davis, Louis G. Michael IV, Christy A. Coghlan, Francisco Servant, Dongyoon Lee
crossref: 2026-09-12

AI 速览

一句话:通过对多语言正则语料库的实证分析,揭示正则表达式跨语言复用存在语义与性能差异及安全风险。

论文研究正则表达式能否作为跨编程语言的通用表示被直接复用。作者先调查158名专业开发者,发现多数人跨语言复用正则,约半数认为其通用。随后构建包含8种语言、193,524个项目、537,806条正则的多语言语料库,实验比较同一正则在不同语言中的编译、语义与性能表现,并结合文档和引擎实现解释差异。结果显示,尽管多数正则可跨语言编译,15%存在语义差异,10%存在性能差异,后者可能带来安全漏洞;还发现JavaScript-V8、Python、Ruby、Rust等正则引擎的缺陷以及数千模块中的潜在问题。

问题
研究正则表达式跨语言复用时是否保持语义与性能特征,以及这种实践是否带来逻辑错误与安全漏洞。
方法
通过开发者调查和大规模多语言正则语料库(8种语言、537,806条正则)进行跨语言编译、语义与性能对比,并借助文档和引擎实现分析差异来源。
评估
对193,524个项目中的正则进行实证评估,量化语义差异(15%)、性能差异(10%)及引擎/模块缺陷,验证正则通用语言假设不成立。
原文摘要(Abstract)

This paper explores the extent to which regular expressions (regexes) are portable across programming languages. Many languages offer similar regex syntaxes, and it would be natural to assume that regexes can be ported across language boundaries. But can regexes be copy/pasted across language boundaries while retaining their semantic and performance characteristics? In our survey of 158 professional software developers, most indicated that they re-use regexes across language boundaries and about half reported that they believe regexes are a universal language.We experimentally evaluated the riskiness of this practice using a novel regex corpus — 537,806 regexes from 193,524 projects written in JavaScript, Java, PHP, Python, Ruby, Go, Perl, and Rust. Using our polyglot regex corpus, we explored the hitherto-unstudied regex portability problems: logic errors due to semantic differences, and security vulnerabilities due to performance differences. We report that developers’ belief in a regex lingua franca is understandable but unfounded. Though most regexes compile across language boundaries, 15% exhibit semantic differences across languages and 10% exhibit performance differences across languages. We explained these differences using regex documentation, and further illuminate our findings by investigating regex engine implementations. Along the way we found bugs in the regex engines of JavaScript-V8, Python, Ruby, and Rust, and potential semantic and performance regex bugs in thousands of modules.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot5101,
  title = {Why aren’t regular expressions a lingua franca? an empirical study on the re-use and portability of regular expressions},
  author = {James C. Davis and Louis G. Michael IV and Christy A. Coghlan and Francisco Servant and Dongyoon Lee},
  booktitle = {FSE},
  year = {2019},
  doi = {10.1145/3338906.3338909}
}