Motivation: Sequence comparison is a fundamental problem in bioinformatics and plays a key role in a wide range of applications. Alignment-free methods provide a computationally efficient alternative to alignment-based methods for large-scale sequence analysis. Several neural network-based methods have recently been developed for this purpose. However, due to the fact that the neural networks employed are not designed specifically for biological sequence analysis, existing methods do not perform well on sequences of varying lengths and are sensitive to the presence of insertions and deletions. Results: In this paper, we describe the development of a new method, referred to as AsMac, that addresses the aforementioned issues. We proposed a novel neural network structure for approximate string matching for the extraction of pertinent information from biological sequences and an efficient gradient computation algorithm for training the constructed neural network. We performed a large-scale benchmark study using real-world data that demonstrated the effectiveness and potential utility of the proposed method. Availability: Open-source software for the proposed method is developed and freely available at www.acsu.buffalo.edu/~yijunsun/lab/AsMac.html . Supplementary information: Supplementary data are available at Bioinformatics online.