Is there a function built into Java that capitalizes the first character of each word in a String, and does not affect the others?
Miles O'Brien(B remains capital, this rules out Title Case)
Old McDonald would be find too, but I don't expect it to be THAT smart.)
A quick look at the Java String Documentation reveals only
toLowerCase(), which of course do not provide the desired behavior. Naturally, Google results are dominated by those two functions. It seems like a wheel that must have been invented already, so it couldn't hurt to ask so I can use it in the future.
I have to rename a complete folder tree recursively so that no uppercase letter appears anywhere (it's C++ sourcecode, but that shouldn't matter). Bonus points for ignoring CVS and SVN control files/folders. Preferred way would be a shell script, since shell should be available at any Linux box.
There were some valid arguments about details of the file renaming.
I think files with same lowercase names should be overwritten, it's the user's problem. When checked out on a case-ignoring file system would overwrite the first one with the latter, too.
I would consider A-Z characters and transform them to a-z, everything else is just calling for problems (at least with source code).
The script would be needed to run a build on a Linux system, so I think changes to CVS or SVN control files should be omitted. After all, it's just a scratch checkout. Maybe an "export" is more appropriate.
I have a database table with a
code column that uses a lowercase index to prevent code values that only differ in case (e.g. 'XYZ' = 'xYZ' = 'xyz'). The typical way in Postgresql is to create a function based index, like this:
CREATE UNIQUE INDEX mytable_lower_code_idx ON mytable (lower(code)).
Now I have a case where I need upsert behaviour on that column:
-- first insertINSERT INTO mytable (code) VALUES ('abcd');-- second insert, with upsert behaviourINSERT INTO mytable (code) VALUES ('Abcd') ON CONFLICT (code) DO UPDATE SET code='Abcd';
For the second insert I get a unique key violation:
ERROR: duplicate key value violates unique constraint "mytable_lower_code_idx"
(I also tried to use
ON CONFLICT ON CONSTRAINT mytable_lower_code_idx but Postgresql tells me that this constraint does not exist so maybe it doesn't treat the index as a constraint.)
My final question: Is there any way to make INSERT ... ON CONFLICT work together with indexes on expressions? Or must I introduce a physical indexed lowercase column to accomplish the task?
Is there a way to convert a string from uppercase, or even part uppercase to lowercase?
E.g. Kilometers --> kilometers.
How can I convert all values in an array to lowercase in PHP?