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

https://doi.org/10.55214/25768484.v9i1.4349

Authors

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.

Section

How to Cite

Insuasty, E. ., & Insuasti, J. . (2025). Comparing the speed of searching for a regular expression versus classic string search functions. Edelweiss Applied Science and Technology, 9(1), 1129–1137. https://doi.org/10.55214/25768484.v9i1.4349

Downloads

Download data is not yet available.

Dimension Badge

Download

Downloads

Issue

Section

Articles

Published

2025-01-20