Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does there exist a analogue of the stringsearch package for Data.Text instead of ByteString?

Tags:

haskell

The stringsearch package provides fast find/replace functionality for Haskell ByteStrings. Does there exist corresponding functionality for the text strings defined in the Data.Text package?

The only approaches I can see at the moment involve encoding to UTF8, using stringsearch, and then converting back---which isn't really ideal!

like image 300
circular-ruin Avatar asked Jul 29 '11 01:07

circular-ruin


1 Answers

Efficient Boyer-Moore search for Text is implemented in the package out of the box. See the source here: http://hackage.haskell.org/packages/archive/text/0.11.1.5/doc/html/src/Data-Text-Search.html

Access to this functionality is through the standard Text API -- splitOn, breakOn, count, replace, and isInfixOf in particular.

like image 181
sclv Avatar answered Oct 03 '22 10:10

sclv