regex vs substring,toUpper, toLower, charAt.. etc

what is your creteria for choosing to use a small function of substrings vs doing the same thing with regex?

it seems like from readability and maintainability standpoints (and maybe understandability in some cases) regex should always be used

in my case, i am building a search engine, and for every result the "sniplet text" should always start with a capital letter, and never a symbol.

should i use substrings / toUppercase to accomplish this, or a simple regex?

[492 byte] By [mkoryaka] at [2007-11-26 15:24:57]
# 1

I dont know what an regex is yet(please fill me in), but I do know that if your gonna do a search engien then you should use equalsIgnoreCase(s) and not toUpperCase or toLowerCase. Also a bit confused about the substring part lol. But I still would recommend to use equalsIgnoreCase(s) as its probably the best way. And I use it on my own page as well..

Also search for parts of the whole word. I guess your gonna make searches against an database in which it should be enough to say: "stri" to find the word "String". If you get what Im saying..

Dingo_no_1a at 2007-7-8 21:40:32 > top of Java-index,Java Essentials,Java Programming...
# 2

> I dont know what an regex is yet(please fill me in),

Then why are you attempting to answer a question about weather or not to use RegEx?

@OP, if read/maintainability are your key concerns, I'd say it's a matter of preference. (So long as you encapsulate and document :) If performance is key, you'll have to benchmark.

bckrispia at 2007-7-8 21:40:32 > top of Java-index,Java Essentials,Java Programming...
# 3

> it seems like from readability and maintainability

> standpoints (and maybe understandability in some

> cases) regex should always be used

That assumes everybody who is going to touch the code knows regexes. You might get away with that in a Perl project, but in Java... ?

uncle_alicea at 2007-7-8 21:40:32 > top of Java-index,Java Essentials,Java Programming...
# 4
everyone should know regex. if they dont know it then maybe they shouldnt have the job. =) ofcourse, thats my opinion.
mkoryaka at 2007-7-8 21:40:32 > top of Java-index,Java Essentials,Java Programming...