commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ha ryon <ha.r...@gmail.com>
Subject [lang] Additions to StringUtils ?
Date Fri, 19 Nov 2004 10:30:28 GMT
- 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


Mime
View raw message