IDEAS home Printed from https://ideas.repec.org/a/ajp/edwast/v9y2025i1p1129-1137id4349.html
   My bibliography  Save this article

Comparing the speed of searching for a regular expression versus classic string search functions

Author

Listed:
  • Edwin Insuasty
  • Jesús Insuasti

Abstract

This study investigates the comparative efficiency of regular expressions and native string search methods in object-oriented programming languages such as Java and C#. String search methods, including Index of, Last Index of, and Contains, are commonly employed in programming tasks. However, their performance often deteriorates with increased text size. By contrast, regular expressions offer a versatile and powerful approach to text search, making them an appealing alternative. The research employed an empirical methodology, evaluating execution times for both approaches on four computers with varying hardware configurations. The dataset consisted of an extended version of Miguel de Cervantes’ Don Quijote de la Mancha, resulting in a text size of over 122 million characters. The experiments revealed that regular expressions significantly outperformed traditional methods, achieving speeds up to 157 times faster on lower-end hardware and maintaining consistent superiority across other configurations. The findings underscore the efficiency of regular expressions for extensive text processing tasks, particularly in computationally constrained environments. Developers are encouraged to adopt regular expressions not only for their speed but also for their robustness in handling complex string operations. This research contributes to the growing knowledge of algorithm performance and provides practical recommendations for optimizing text search in programming applications.

Suggested Citation

  • Edwin Insuasty & Jesús Insuasti, 2025. "Comparing the speed of searching for a regular expression versus classic string search functions," Edelweiss Applied Science and Technology, Learning Gate, vol. 9(1), pages 1129-1137.
  • Handle: RePEc:ajp:edwast:v:9:y:2025:i:1:p:1129-1137:id:4349
    as

    Download full text from publisher

    File URL: https://learning-gate.com/index.php/2576-8484/article/view/4349/1674
    Download Restriction: no
    ---><---

    Corrections

    All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:ajp:edwast:v:9:y:2025:i:1:p:1129-1137:id:4349. See general information about how to correct material in RePEc.

    If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

    We have no bibliographic references for this item. You can help adding them by using this form .

    If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.

    For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Melissa Fernandes (email available below). General contact details of provider: https://learning-gate.com/index.php/2576-8484/ .

    Please note that corrections may take a couple of weeks to filter through the various RePEc services.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.