Journal of the Association for Computing Machinery, Vol. 43, No. 6, November 1996, pp. 915–936.

Fast Text Searching for Regular Expressions or Automaton Searching on Tries

RICARDO A. BAEZA-YATES

AND

GASTON H. GONNET

Abstract. We present algorithms for efficient searching of regular expressions on preprocessed text, using a Patricia tree as a logical model for the index. We obtain searching algorithms that run in logarithmic expected time in the size of the text for a wide subclass of regular expressions, and in sublinear expected time for any regular expression. This is the first such algorithm to be found with this complexity.

Categories and Subject Descriptors. E.1 [Data Structures]; F.2 [Analysis of Algorithms and Problem Complexity]; H.3.3 [Information Storage and Retrieval]: Information Search and Retrieval; I.5.4 [Pattern Recognition]: Applications—text processing

General Terms. Algorithms

Additional Key words and Phrases. Digital trees, finite automata, regular expressions, text searching

Copyright 1996 by ACM, Inc. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or direct commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from Publications Dept, ACM Inc., fax +1 (212) 869-0481, or permissions@acm.org.