commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory" <ggreg...@seagullsoftware.com>
Subject RE: [lang] Additions to StringUtils ?
Date Fri, 19 Nov 2004 17:56:02 GMT

If you factor ORO-RegExp calls into a single method, you'll have your
one-liners ;-)

Gary

-----Original Message-----
From: Ha ryon [mailto:ha.ryon@gmail.com] 
Sent: Friday, November 19, 2004 2:30 AM
To: commons-user@jakarta.apache.org
Subject: [lang] Additions to StringUtils ?

- I would like to be able to split a string using a String (more than
one character long) separator.
split("John:Arthur::Renaud:Sylvan::me:you", "::") ->[ "John;Arthur",
"Renaud:Sylvan", "me:you" ]

- I would like to fastly join and quote at the same time :
join(["me", "you", "them"], "|", "<", ">") -> "<me>|<you>|<them>"
basically, I would usually use it to turn an array into some
javascript or sql list :
join( ["me", "you", "them"], ", ", "'", "'") -> "'me', 'you', 'them'" 
and then "select * from guys where name in (" + ... + ")". Idem with
generating some javascript to a jsp.

- then split such a quoted string back to an array.
split("'me', 'you', 'them'", ", ", "'", "'") -> ["me", "you", "them"]


(I know I can do all of this with regexp, or a bit of work, but the
question is always can i do it with one line :) --- ** lazy !! **)

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message