What is the best practice?
<HTML> or <html>
And why we should stick with one particular case?
However all browsers seems to interpret both cases and returns the expected output.
Assume a multi-line text file file
in which some lines start with whitespaces.
$ cat filefoo Baz baz QUX QUx QuuxBaZ QuxBazaaR
Further assume that I wish to convert all those lines that start with a keyword (e.g. "baz") to lowercase letters, irrespective if (a) that keyword is written in lower- or uppercase letters (or any combination thereof) itself, and (b) that keyword is preceeded by whitespaces.
$ cat file | sought_commandfoo Baz # not to lowercase (line does not start with keyword) baz qux # to lowercase QUx Quuxbaz qux # to lowercaseBazaaR # not to lowercase (line does not start with keyword, but merely with a word containing the keyword)
I believe that awk is the tool to do it, but I am uncertain how to implement the case-insensitivity for the keyword matching.
$ cat file | awk '{ if($1 ~ /^ *baz/) print tolower($0); else print $0}'foo Baz baz qux QUx QuuxBaZ Qux # ERROR HERE: was not replaced, b/c keyword not recognized.BazaaR
EDIT 1:Adding IGNORECASE=1
appears to resolve the case-insensitivity, but now incorrectly converts the last line to lowercase.
$ cat file | awk '{IGNORECASE=1; if($1~/^ *baz/) print tolower($0); else print $0}'foo Baz baz qux QUx Quuxbaz quxbazaar # ERROR HERE: should not be converted to lowercase, as keyword not present (emphasis on word!).
I have a dataframe like the one displayed below:
# Create an example dataframe about a fictional armyraw_data = {'regiment': ['Nighthawks', 'Nighthawks', 'Nighthawks', 'Nighthawks'], 'company': ['1st', '1st', '2nd', '2nd'], 'deaths': ['kkk', 52, '25', 616], 'battles': [5, '42', 2, 2], 'size': ['l', 'll', 'l', 'm']}df = pd.DataFrame(raw_data, columns = ['regiment', 'company', 'deaths', 'battles', 'size'])
My goal is to transform every single string inside of the dataframe to upper case so that it looks like this:
Notice: all data types are objects and must not be changed; the output must contain all objects. I want to avoid to convert every single column one by one... I would like to do it generally over the whole dataframe possibly.
What I tried so far is to do this but without success
df.str.upper()
Is there a function built into Java that capitalizes the first character of each word in a String, and does not affect the others?
Examples:
jon skeet
-> Jon Skeet
miles o'Brien
-> Miles O'Brien
(B remains capital, this rules out Title Case)old mcdonald
-> Old Mcdonald
**(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 toUpperCase()
and 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.
บ้าน - แผนผังเว็บไซต์ - ความเป็นส่วนตัว - ลิงค์ - Copyright © 2019 Cortex IT Ltd : ติดต่อ : admin @ cortexit.co.uk
Please note that by viewing our site you agree to our use of cookies (see ความเป็นส่วนตัว for details). You will only see this message once.