Comparing the speed of searching for a regular expression versus classic string search functions - Insuasty, Edwin; Insuasti, Jesús (Edelweiss Applied Science and Technology, 2025)
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.