Lune

ASE2024Top-tier venue

Repairing Regex-Dependent String Functions

Nariyoshi Chida, Tachio Terauchi

Abstract

Regex-dependent string functions are string functions that take regular expressions (regexes) as parameters and are popular means of manipulating strings. They are frequently used for, e.g., string transformation and substring search. Despite the importance, writing these functions is far from easy. To rectify this situation, recent research made significant progress by proposing automated methods for synthesizing regexes based on Programming by Examples (PBE). However, there still is a gap between these methods and the goal of synthesizing regex-dependent string functions. First, the existing methods focus on whole-string matching, whereas most regex-dependent string functions adopt substring matching. Second, the existing methods focus only on the regex, but many commonly used regex-dependent string functions, such as replace and replaceAll, also take as parameter a replacement to specify how the substrings matched to the regex will be replaced. This paper fills the gap by presenting the first PBE-based method for repairing regex-dependent string functions. Like the recent methods for regex synthesis, our algorithm builds on enumerative search with pruning and SMT constraint solving, but with extensions to support substring matching and replacement. The main challenge is the large search space. We address the challenge by novel ideas such as incorporation of origin information in examples to identify the locations of substrings to be matched, a new substring-context-aware pruning technique, and a novel use of SMT constraints to insert captures that can be referred from the replacement. Additionally, we identify a novel necessary and sufficient condition that can be used to detect and filter unrepairable instances. We implemented our algorithm as a prototype tool called R2-DS and evaluated it on real-world benchmarks. Results show that our algorithm efficiently repairs the bugs in the real world and finds high-quality repairs.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

1 top-tier paper has cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • TRANSREGEX: Multi-modal Regular Expression Synthesis by Generate-and-Repair cites Multi-modal synthesis of regular expressions
  • Formal Verification for JavaScript Regular Expressions: A Proven Mechanized Semantics and Its Applications cites Solving string constraints with Regex-dependent functions through transducers with priorities and variables
  • Interactive Program Synthesis by Augmented Examples cites Multi-modal synthesis of regular expressions
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers1

  1. Formal Verification for JavaScript Regular Expressions: A Proven Mechanized Semantics and Its ApplicationsAurèle Barrière, Victor Deng, Clément Pit-ClaudelPOPL 2026

Builds on8

  1. Multi-modal synthesis of regular expressionsQiaochu Chen, Xinyu Wang, Xi Ye, Greg Durrett et al.PLDI 2020 · 81 citations
  2. Interactive Program Synthesis by Augmented ExamplesTianyi Zhang, London Lowmanstone, Xinyu Wang, Elena L. GlassmanUIST 2020 · 57 citations
  3. Solving string constraints with Regex-dependent functions through transducers with priorities and variablesTaolue Chen, Alejandro Flores-Lamas, Matthew Hague, Zhilei Han et al.POPL 2022 · 39 citations
  4. No Strings Attached: An Empirical Study of String-related Software BugsAryaz Eghbali, Michael PradelASE 2020 · 17 citations
  5. TRANSREGEX: Multi-modal Regular Expression Synthesis by Generate-and-RepairYeting Li, Shuaimin Li, Zhiwu Xu, Jialun Cao et al.ICSE 2021 · 16 citations

Related papers

  1. Repairing Regex-Dependent String-Manipulation ProgramsNariyoshi Chida, Tachio TerauchiCAV 2026
  2. Repairing Regular Expressions for ExtractionNariyoshi Chida, Tachio TerauchiPLDI 2023 · 9 citations
  3. Spine: Scaling up Programming-by-Negative-Example for String Filtering and TransformationChaoji Zuo, Sepehr Assadi, Dong DengSIGMOD 2022 · 4 citations
  4. SynGuar: guaranteeing generalization in programming by exampleBo Wang, Teodora Baluta, Aashish Kolluri, Prateek SaxenaFSE 2021
  5. FlashRegex: Deducing Anti-ReDoS Regexes from ExamplesYeting Li, Zhiwu Xu, Jialun Cao, Haiming Chen et al.ASE 2020 · 17 citations
Dusk over the sea between two cliffs drawn in fine vertical lines