case-conversion

gnuplot - convert a string variable to lowercase

牧云@^-^@ 提交于 2021-02-19 05:19:33
问题 How do you convert a string to lowercase in gnuplot? This is a gnuplot string handling question. Example:- I wish to check a user typed parameter in a gnuplot script.... if (tolower(ARG2) == "ohms") {..... so by accepting "ohms", "Ohms", or "OHMS". The preference is to not need to use an external "system" command so that the script is more portable. My current best solution is arg2 = system("awk 'BEGIN { print toupper(\"".ARG2."\") }'") and then test the new string variable "arg2", but awk

gnuplot - convert a string variable to lowercase

时光总嘲笑我的痴心妄想 提交于 2021-02-19 05:17:31
问题 How do you convert a string to lowercase in gnuplot? This is a gnuplot string handling question. Example:- I wish to check a user typed parameter in a gnuplot script.... if (tolower(ARG2) == "ohms") {..... so by accepting "ohms", "Ohms", or "OHMS". The preference is to not need to use an external "system" command so that the script is more portable. My current best solution is arg2 = system("awk 'BEGIN { print toupper(\"".ARG2."\") }'") and then test the new string variable "arg2", but awk

How can I convert from underscores to camel case with a regex?

假如想象 提交于 2019-12-30 05:38:09
问题 How can I convert names with underscores into camel case names as follows using a single Java/Perl regular expression search and replace? underscore_variable_name -> underscoreVariableName UNDERSCORE_VARIABLE_NAME -> underscoreVariableName _LEADING_UNDERSCORE -> leadingUnderscore The reason I ask for a single regular expressions is that I want to do this using Eclipse or Notepad++ search and replace. 回答1: Some Perl examples: my $str = 'variable_name, VARIABLE_NAME, _var_x_short, __variable_

C / C++ UTF-8 upper/lower case conversions

北城以北 提交于 2019-12-18 02:41:14
问题 The Problem: There is a method with a corresponding test-case that works on one machine and fails on the other (details below). I assume there's something wrong with the code, causing it to work by chance on the one machine. Unfortunately I cannot find the problem. Please note that the usage of std::string and utf-8 encoding are requirements I have no real influence on. Using C++ methods would be totally fine, but unfortunately I failed to find anything. Hence the use of C-functions. The

Perl, using tr function to convert uppercase to lowercase and vice-versa at the same time?

♀尐吖头ヾ 提交于 2019-12-08 15:46:44
问题 I have a string $string= 'AbCdEf'; and I want to use the tr function to convert all the uppercase letters to lower case and all the lower case to upper case.... at the same time. I basically just want to reverse it to become. aBcDeF I came up with this line, but I'm not sure how to modify it to do what I want. Any help please? $string=~ tr/A-Z/a-z/; Thanks! 回答1: $string =~ tr/A-Za-z/a-zA-Z/; 回答2: At Tom's request, the Unicode-clean (or locales-clean) version: s/([[:upper:]])|([[:lower:]])

PHP - add underscores before capital letters

混江龙づ霸主 提交于 2019-12-05 09:59:31
问题 How can I replace a set of words that look like: SomeText to Some_Text ? 回答1: This can easily be achieved using a regular expression: $result = preg_replace('/\B([A-Z])/', '_$1', $subject); a brief explanation of the regex: \B asserts position at a word boundary. [A-Z] matches any uppercase characters from A-Z. () wraps the match in a back reference number 1. Then we replace with '_$1' which means replace the match with an [underscore + backreference 1] 回答2: $s1 = "ThisIsATest"; $s2 = preg

Convert Unicode/UTF-8 string to lower/upper case using pure & pythonic library

感情迁移 提交于 2019-12-04 17:48:25
问题 I use Google App Engine and cannot use any C/C++ extension, just pure & pythonic library to do conversion of Unicode/UTF-8 strings to lower/upper case. str.lower() and string.lowercase() don't. 回答1: str encoded in UTF-8 and unicode are two different types. Don't use string , use the appropriate method on the unicode object: >>> print u'ĉ'.upper() Ĉ Decode str to unicode before using: >>> print 'ĉ'.decode('utf-8').upper() Ĉ 来源: https://stackoverflow.com/questions/2145826/convert-unicode-utf-8

Conversion of string to upper case without inbuilt methods

点点圈 提交于 2019-12-04 07:28:17
问题 I am trying to perform conversion from a lowercase to uppercase on a string without using any inbuilt functions (other than ord() and char()). Following the logic presented on a different thread here , I came up with this. def uppercase(str_data): ord('str_data') str_data = str_data -32 chr('str_data') return str_data print(uppercase('abcd')) However I am getting an error output: TypeError: ord() expected a character, but string of length 8 found.What am I missing here? 回答1: You need to

PHP - add underscores before capital letters

泄露秘密 提交于 2019-12-03 22:26:04
How can I replace a set of words that look like: SomeText to Some_Text ? This can easily be achieved using a regular expression: $result = preg_replace('/\B([A-Z])/', '_$1', $subject); a brief explanation of the regex: \B asserts position at a word boundary. [A-Z] matches any uppercase characters from A-Z. () wraps the match in a back reference number 1. Then we replace with '_$1' which means replace the match with an [underscore + backreference 1] $s1 = "ThisIsATest"; $s2 = preg_replace("/(?<=[a-zA-Z])(?=[A-Z])/", "_", $s1); echo $s2; // "This_Is_A_Test" Explanation: The regex uses two look

Conversion of string to upper case without inbuilt methods

痴心易碎 提交于 2019-12-02 13:07:50
I am trying to perform conversion from a lowercase to uppercase on a string without using any inbuilt functions (other than ord() and char()). Following the logic presented on a different thread here , I came up with this. def uppercase(str_data): ord('str_data') str_data = str_data -32 chr('str_data') return str_data print(uppercase('abcd')) However I am getting an error output: TypeError: ord() expected a character, but string of length 8 found.What am I missing here? You need to execute ord() for each character of your input string. instead of the input string: def uppercase(str_data):