EconPapers    
Economics at your fingertips  
 

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

Edwin Insuasty () and Jesús Insuasti ()

Edelweiss Applied Science and Technology, 2025, vol. 9, issue 1, 1129-1137

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.

Keywords: Algorithms; Expressions; Methods; Regular; Search; String. (search for similar items in EconPapers)
Date: 2025
References: Add references at CitEc
Citations:

Downloads: (external link)
https://learning-gate.com/index.php/2576-8484/article/view/4349/1674 (application/pdf)

Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.

Export reference: BibTeX RIS (EndNote, ProCite, RefMan) HTML/Text

Persistent link: https://EconPapers.repec.org/RePEc:ajp:edwast:v:9:y:2025:i:1:p:1129-1137:id:4349

Access Statistics for this article

More articles in Edelweiss Applied Science and Technology from Learning Gate
Bibliographic data for series maintained by Melissa Fernandes ().

 
Page updated 2025-03-19
Handle: RePEc:ajp:edwast:v:9:y:2025:i:1:p:1129-1137:id:4349