Questions tagged [case-conversion]
28 questions
282
votes
12 answers
Converting camel case to underscore case in ruby
Is there any ready function which converts camel case Strings into underscore separated string?
I want something like this:
"CamelCaseString".to_underscore
to return "camel_case_string".
...

Daniel Cukier
- 11,502
- 15
- 68
- 123
131
votes
6 answers
How can I convert a string to upper- or lower-case with XSLT?
How do you do case conversion in XSL?
UPPER CASE

mjs
- 63,493
- 27
- 91
- 122
88
votes
11 answers
Javascript convert PascalCase to underscore_case/snake_case
How can I convert PascalCase string into underscore_case/snake_case string? I need to convert dots into underscores as well.
eg. convert
TypeOfData.AlphaBeta
into
type_of_data_alpha_beta

zahmati
- 1,261
- 1
- 10
- 18
43
votes
11 answers
How can I convert text to Pascal case?
I have a variable name, say "WARD_VS_VITAL_SIGNS", and I want to convert it to Pascal case format: "WardVsVitalSigns"
WARD_VS_VITAL_SIGNS -> WardVsVitalSigns
How can I make this conversion?

wlz
- 563
- 1
- 4
- 9
41
votes
7 answers
camelCase to underscore in vi(m)
If for some reason I want to selectively convert camelCase named things to being underscore separated in vim, how could I go about doing so?
Currently I've found that I can do a search /s[a-z][A-Z] and record a macro to add an underscore and convert…

Jeff
- 1,807
- 1
- 15
- 17
28
votes
4 answers
How can I convert from underscores to camel case with a regex?
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 ->…

Jeff Axelrod
- 27,676
- 31
- 147
- 246
24
votes
5 answers
PHP - add underscores before capital letters
How can I replace a set of words that look like:
SomeText
to
Some_Text
?

Alex
- 66,732
- 177
- 439
- 641
17
votes
5 answers
C / C++ UTF-8 upper/lower case conversions
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…

b.buchhold
- 3,837
- 2
- 24
- 33
16
votes
2 answers
What's the correct way to treat numbers in snake case?
If I want to write a phrase like "Column 1" in snake case (the usual C way of formatting identifiers that looks like some_function), do I insert underscore between a word or a number, like column_1, or not, like column1?
That may be a painfully…

Max Yankov
- 12,551
- 12
- 67
- 135
13
votes
2 answers
Unicode characters having asymmetric upper/lower case. Why?
Why do the following three characters have not symmetric toLower, toUpper results
/**
* Written in the Scala programming language, typed into the Scala REPL.
* Results commented accordingly.
*/
/* Unicode Character 'LATIN CAPITAL LETTER SHARP…

Tim Friske
- 2,012
- 1
- 18
- 28
11
votes
1 answer
Convert Unicode/UTF-8 string to lower/upper case using pure & pythonic library
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.

Viet
- 17,944
- 33
- 103
- 135
10
votes
3 answers
Perl, using tr function to convert uppercase to lowercase and vice-versa at the same time?
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…

Brian
- 4,023
- 8
- 29
- 36
3
votes
3 answers
gnuplot - convert a string variable to lowercase
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".…

mjp
- 93
- 10
2
votes
0 answers
How to prevent change of case of user-defined components in ReactJS while using react-html-parser?
I am trying to convert below string rawJSX to JSX using react-html-parser.
import ReactHtmlParser from "react-html-parser";
function StrToJSX() {
let rawJSX = ` I am a programmer. `;
…
Hello World!

Deepanshu Yadav
- 93
- 1
- 2
- 8
2
votes
2 answers
How to use Regex to convert initial letter of a string to upper case
Given a bunch of strings in an editor (e.g., Rubymine or IntelliJ) that look like this:
list: ["required","TBD at time of entry", "respirator, gloves, coveralls, etc."]
How can I use the built-in Regex search and replace to convert the initial…

Jon Kern
- 3,186
- 32
- 34