You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by "David M. Karr" <dk...@tcsi.com> on 2000/11/01 19:36:03 UTC

Simple strategy to tell if a string is an RE?

I would assume that matching a string against an RE is a somewhat
expensive operation, compared to a "String.indexOf() != -1"
operation.

Is there a simple strategy for quickly determining whether a string is
an RE?  If there was a set of characters which could be in an RE, then
you'd have to check for each one in a loop.  It's still possible this
could be less expensive than matching a string against a "primitive"
RE (a plain substring).

Has anyone determined the performance of "primitive" REs against
simple "indexOf" searches?

-- 
===============================================================================
David M. Karr     ; dkarr@tcsi.com  ; w:(425)487-8312 ; TCSI & Best Consulting
Software Engineer ; Unix/Java/C++/X ; BrainBench CJ12P (#12004)