### String Case Conversion Examples Source: https://github.com/okunishinishi/python-stringcase/blob/master/README.rst Demonstrates various string case conversions using the stringcase library. Ensure the library is installed (`pip install stringcase`). ```python import stringcase stringcase.camelcase('foo_bar_baz') # => "fooBarBaz" stringcase.camelcase('FooBarBaz') # => "fooBarBaz" ``` ```python stringcase.capitalcase('foo_bar_baz') # => "Foo_bar_baz" stringcase.capitalcase('FooBarBaz') # => "FooBarBaz" ``` ```python stringcase.constcase('foo_bar_baz') # => "FOO_BAR_BAZ" stringcase.constcase('FooBarBaz') # => "_FOO_BAR_BAZ" ``` ```python stringcase.lowercase('foo_bar_baz') # => "foo_bar_baz" stringcase.lowercase('FooBarBaz') # => "foobarbaz" ``` ```python stringcase.pascalcase('foo_bar_baz') # => "FooBarBaz" stringcase.pascalcase('FooBarBaz') # => "FooBarBaz" ``` ```python stringcase.pathcase('foo_bar_baz') # => "foo/bar/baz" stringcase.pathcase('FooBarBaz') # => "/foo/bar/baz" ``` ```python stringcase.sentencecase('foo_bar_baz') # => "Foo bar baz" stringcase.sentencecase('FooBarBaz') # => "Foo bar baz" ``` ```python stringcase.snakecase('foo_bar_baz') # => "foo_bar_baz" stringcase.snakecase('FooBarBaz') # => "foo_bar_baz" ``` ```python stringcase.spinalcase('foo_bar_baz') # => "foo-bar-baz" stringcase.spinalcase('FooBarBaz') # => "-foo-bar-baz" ``` ```python stringcase.titlecase('foo_bar_baz') # => "Foo Bar Baz" stringcase.titlecase('FooBarBaz') # => " Foo Bar Baz" ``` ```python stringcase.trimcase('foo_bar_baz') # => "foo_bar_baz" stringcase.trimcase('FooBarBaz') # => "FooBarBaz" ``` ```python stringcase.uppercase('foo_bar_baz') # => "FOO_BAR_BAZ" stringcase.uppercase('FooBarBaz') # => "FOOBARBAZ" ``` ```python stringcase.alphanumcase('_Foo., Bar') # =>'FooBar' stringcase.alphanumcase('Foo_123 Bar!') # =>'Foo123Bar' ``` -------------------------------- ### Installation Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Install the stringcase library using pip. ```APIDOC ## Installation ```bash pip install stringcase ``` ``` -------------------------------- ### Install stringcase Package Source: https://github.com/okunishinishi/python-stringcase/blob/master/README.rst Use pip to install the stringcase library. This command should be run in your terminal or command prompt. ```bash $ pip install stringcase ``` -------------------------------- ### Convert to titlecase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings into title case where each word starts with an uppercase letter. ```python import stringcase # Convert to Title Case stringcase.titlecase('fooBar') # => 'Foo Bar' stringcase.titlecase('foo_bar') # => 'Foo Bar' stringcase.titlecase('foo-bar') # => 'Foo Bar' stringcase.titlecase('foo.bar') # => 'Foo Bar' stringcase.titlecase('_bar_baz') # => ' Bar Baz' stringcase.titlecase('.bar_baz') # => ' Bar Baz' stringcase.titlecase('') # => '' stringcase.titlecase(None) # => 'None' ``` -------------------------------- ### Convert to pascalcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings to PascalCase where each word starts with an uppercase letter and there are no separators. ```python import stringcase # Convert to PascalCase stringcase.pascalcase('foo_bar') # => 'FooBar' stringcase.pascalcase('foo-bar') # => 'FooBar' stringcase.pascalcase('foo.bar') # => 'FooBar' stringcase.pascalcase('_bar_baz') # => 'BarBaz' stringcase.pascalcase('.bar_baz') # => 'BarBaz' stringcase.pascalcase('') # => '' stringcase.pascalcase(None) # => 'None' ``` -------------------------------- ### Convert to camelCase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Transforms strings into camelCase format where the first word is lowercase and subsequent words start with uppercase letters. ```python import stringcase # Convert from various formats to camelCase stringcase.camelcase('foo_bar') # => 'fooBar' stringcase.camelcase('FooBar') # => 'fooBar' stringcase.camelcase('foo-bar') # => 'fooBar' stringcase.camelcase('foo.bar') # => 'fooBar' stringcase.camelcase('_bar_baz') # => 'barBaz' stringcase.camelcase('.bar_baz') # => 'barBaz' stringcase.camelcase('') # => '' stringcase.camelcase(None) # => 'none' ``` -------------------------------- ### pascalcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string into Pascal case (UpperCamelCase) where each word starts with an uppercase letter and there are no separators. ```APIDOC ## pascalcase ### Description Converts a string into Pascal case (also known as UpperCamelCase) where each word starts with an uppercase letter and there are no separators between words. ### Method `stringcase.pascalcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Convert to PascalCase stringcase.pascalcase('foo_bar') stringcase.pascalcase('foo-bar') stringcase.pascalcase('foo.bar') stringcase.pascalcase('_bar_baz') stringcase.pascalcase('.bar_baz') stringcase.pascalcase('') stringcase.pascalcase(None) ``` ### Response #### Success Response (200) Returns the Pascal-cased string. #### Response Example ``` 'FooBar' 'FooBar' 'FooBar' 'BarBaz' 'BarBaz' '' 'None' ``` ``` -------------------------------- ### camelcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string into camel case format. The first word is lowercase and subsequent words start with uppercase letters, with no separators. ```APIDOC ## camelcase ### Description Converts a string into camel case format where the first word is lowercase and subsequent words start with uppercase letters, with no separators between words. ### Method `stringcase.camelcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Convert from various formats to camelCase stringcase.camelcase('foo_bar') stringcase.camelcase('FooBar') stringcase.camelcase('foo-bar') stringcase.camelcase('foo.bar') stringcase.camelcase('_bar_baz') stringcase.camelcase('.bar_baz') stringcase.camelcase('') stringcase.camelcase(None) ``` ### Response #### Success Response (200) Returns the camel-cased string. #### Response Example ``` 'fooBar' 'fooBar' 'fooBar' 'fooBar' 'barBaz' 'barBaz' '' 'none' ``` ``` -------------------------------- ### Title Case Conversion Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string to title case, where each word starts with an uppercase letter and words are separated by spaces. ```APIDOC ## Title Case Conversion ### Description Converts a string into title case where each word starts with an uppercase letter and words are separated by spaces. ### Method `stringcase.titlecase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.titlecase('fooBar') ``` ### Response #### Success Response (200) - **string** - The converted string in title case. #### Response Example ``` 'Foo Bar' ``` ``` -------------------------------- ### Convert to dotcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings into dot case, commonly used for package names and configuration keys. ```python import stringcase # Convert to dot.case stringcase.dotcase('fooBar') # => 'foo.bar' stringcase.dotcase('foo_bar') # => 'foo.bar' stringcase.dotcase('foo-bar') # => 'foo.bar' stringcase.dotcase('FooBarBaz') # => 'foo.bar.baz' ``` -------------------------------- ### Convert to pathcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings into path case using forward slashes as separators, suitable for file paths or URLs. ```python import stringcase # Convert to path/case stringcase.pathcase('fooBar') # => 'foo/bar' stringcase.pathcase('foo_bar') # => 'foo/bar' stringcase.pathcase('foo-bar') # => 'foo/bar' stringcase.pathcase('foo.bar') # => 'foo/bar' stringcase.pathcase('_bar_baz') # => '/bar/baz' stringcase.pathcase('.bar_baz') # => '/bar/baz' stringcase.pathcase('') # => '' stringcase.pathcase(None) # => 'none' ``` -------------------------------- ### Convert to sentencecase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings into sentence case with the first letter capitalized and words separated by spaces. ```python import stringcase # Convert to Sentence case stringcase.sentencecase('fooBar') # => 'Foo bar' stringcase.sentencecase('foo_bar') # => 'Foo bar' stringcase.sentencecase('foo-bar') # => 'Foo bar' stringcase.sentencecase('foo.bar') # => 'Foo bar' stringcase.sentencecase('_bar_baz') # => 'Bar baz' stringcase.sentencecase('.bar_baz') # => 'Bar baz' stringcase.sentencecase('') # => '' stringcase.sentencecase(None) # => 'None' ``` -------------------------------- ### Convert to uppercase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts the entire string to uppercase. ```python import stringcase # Convert to all uppercase stringcase.uppercase('foo') # => 'FOO' stringcase.uppercase('foo_bar') # => 'FOO_BAR' stringcase.uppercase('') # => '' stringcase.uppercase(None) # => 'NONE' ``` -------------------------------- ### Convert to spinal-case Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Transforms strings into kebab-case format where words are separated by hyphens. ```python stringcase.spinalcase('fooBar') # => 'foo-bar' stringcase.spinalcase('foo_bar') # => 'foo-bar' stringcase.spinalcase('foo-bar') # => 'foo-bar' stringcase.spinalcase('foo.bar') # => 'foo-bar' stringcase.spinalcase('_bar_baz') # => '-bar-baz' stringcase.spinalcase('.bar_baz') # => '-bar-baz' stringcase.spinalcase('') # => '' stringcase.spinalcase(None) # => 'none' ``` -------------------------------- ### uppercase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts an entire string to uppercase letters. ```APIDOC ## uppercase ### Description Converts an entire string to uppercase letters. ### Method `stringcase.uppercase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Convert to all uppercase stringcase.uppercase('foo') stringcase.uppercase('foo_bar') stringcase.uppercase('') stringcase.uppercase(None) ``` ### Response #### Success Response (200) Returns the uppercase string. #### Response Example ``` 'FOO' 'FOO_BAR' '' 'NONE' ``` ``` -------------------------------- ### capitalcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string so that the first letter is uppercase while preserving the rest of the string as-is. ```APIDOC ## capitalcase ### Description Converts a string so that the first letter is uppercase while preserving the rest of the string as-is. ### Method `stringcase.capitalcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Capitalize the first letter only stringcase.capitalcase('fooBar') stringcase.capitalcase('foo_bar') stringcase.capitalcase('') ``` ### Response #### Success Response (200) Returns the capital-cased string. #### Response Example ``` 'FooBar' 'Foo_bar' '' ``` ``` -------------------------------- ### Convert to backslashcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings into backslash case, useful for Windows-style file paths. ```python import stringcase # Convert to backslash\case stringcase.backslashcase('fooBar') # => 'foo\\bar' stringcase.backslashcase('foo_bar') # => 'foo\\bar' stringcase.backslashcase('foo-bar') # => 'foo\\bar' stringcase.backslashcase('foo.bar') # => 'foo\\bar' ``` -------------------------------- ### Convert to lowercase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts the entire string to lowercase. ```python import stringcase # Convert to all lowercase stringcase.lowercase('Foo') # => 'foo' stringcase.lowercase('FOO_BAR') # => 'foo_bar' stringcase.lowercase('') # => '' stringcase.lowercase(None) # => 'none' ``` -------------------------------- ### lowercase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts an entire string to lowercase letters. ```APIDOC ## lowercase ### Description Converts an entire string to lowercase letters. ### Method `stringcase.lowercase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Convert to all lowercase stringcase.lowercase('Foo') stringcase.lowercase('FOO_BAR') stringcase.lowercase('') stringcase.lowercase(None) ``` ### Response #### Success Response (200) Returns the lowercase string. #### Response Example ``` 'foo' 'foo_bar' '' 'none' ``` ``` -------------------------------- ### Convert to spinalcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings to spinal case (kebab-case) with all lowercase letters and hyphen separators. ```python import stringcase # Convert to spinal-case stringcase.spinalcase('fooBar') # => 'foo-bar' stringcase.spinalcase('foo_bar') # => 'foo-bar' stringcase.spinalcase('foo-bar') # => 'foo-bar' stringcase.spinalcase('foo.bar') # => 'foo-bar' stringcase.spinalcase('_bar_baz') # => '-bar-baz' stringcase.spinalcase('.bar_baz') # => '-bar-baz' stringcase.spinalcase('') # => '' stringcase.spinalcase(None) # => 'none' ``` -------------------------------- ### Path Case Conversion Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string to path case, where words are separated by forward slashes. ```APIDOC ## Path Case Conversion ### Description Converts a string into path case where words are separated by forward slashes. This is useful for generating file paths or URL segments. ### Method `stringcase.pathcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.pathcase('fooBar') ``` ### Response #### Success Response (200) - **string** - The converted string in path case. #### Response Example ``` 'foo/bar' ``` ``` -------------------------------- ### Convert to capitalcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Capitalizes the first letter of the string while leaving the rest of the string unchanged. ```python import stringcase # Capitalize the first letter only stringcase.capitalcase('fooBar') # => 'FooBar' stringcase.capitalcase('foo_bar') # => 'Foo_bar' stringcase.capitalcase('') # => '' ``` -------------------------------- ### spinalcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string into spinal case (kebab-case) where all letters are lowercase and words are separated by hyphens. ```APIDOC ## spinalcase ### Description Converts a string into spinal case (also known as kebab-case) where all letters are lowercase and words are separated by hyphens. This format is commonly used in URLs and CSS class names. ### Method `stringcase.spinalcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Convert to spinal-case # Example usage would follow here if provided in the source text. ``` ### Response #### Success Response (200) Returns the spinal-cased string. #### Response Example ``` # Example response would follow here if provided in the source text. ``` ``` -------------------------------- ### Convert to snakecase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings to snake_case with all lowercase letters and underscore separators. ```python import stringcase # Convert to snake_case stringcase.snakecase('fooBar') # => 'foo_bar' stringcase.snakecase('foo_bar') # => 'foo_bar' stringcase.snakecase('foo-bar') # => 'foo_bar' stringcase.snakecase('foo.bar') # => 'foo_bar' stringcase.snakecase('_bar_baz') # => '_bar_baz' stringcase.snakecase('.bar_baz') # => '_bar_baz' stringcase.snakecase('') # => '' stringcase.snakecase(None) # => 'none' ``` -------------------------------- ### Trim Whitespace Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Removes leading and trailing whitespace from a string. ```APIDOC ## Trim Whitespace ### Description Removes leading and trailing whitespace from a string. ### Method `stringcase.trimcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.trimcase(' foo bar baz ') ``` ### Response #### Success Response (200) - **string** - The string with leading and trailing whitespace removed. #### Response Example ``` 'foo bar baz' ``` ``` -------------------------------- ### Spinal Case Conversion Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string to spinal-case (kebab-case), where words are separated by hyphens. ```APIDOC ## Spinal Case Conversion ### Description Converts a string into spinal case (kebab-case) where words are separated by hyphens. This is useful for creating URL slugs or CSS class names. ### Method `stringcase.spinalcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.spinalcase('fooBar') ``` ### Response #### Success Response (200) - **string** - The converted string in spinal-case. #### Response Example ``` 'foo-bar' ``` ``` -------------------------------- ### constcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string into constant case (upper snake case) where all letters are uppercase and words are separated by underscores. ```APIDOC ## constcase ### Description Converts a string into constant case (upper snake case) where all letters are uppercase and words are separated by underscores. This format is commonly used for constants in many programming languages. ### Method `stringcase.constcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Convert to CONSTANT_CASE stringcase.constcase('fooBar') stringcase.constcase('foo_bar') stringcase.constcase('foo-bar') stringcase.constcase('foo.bar') stringcase.constcase('_bar_baz') stringcase.constcase('.bar_baz') stringcase.constcase('') stringcase.constcase(None) ``` ### Response #### Success Response (200) Returns the constant-cased string. #### Response Example ``` 'FOO_BAR' 'FOO_BAR' 'FOO_BAR' 'FOO_BAR' '_BAR_BAZ' '_BAR_BAZ' '' 'NONE' ``` ``` -------------------------------- ### Convert to constcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts strings to constant case (upper snake case) with all uppercase letters and underscore separators. ```python import stringcase # Convert to CONSTANT_CASE stringcase.constcase('fooBar') # => 'FOO_BAR' stringcase.constcase('foo_bar') # => 'FOO_BAR' stringcase.constcase('foo-bar') # => 'FOO_BAR' stringcase.constcase('foo.bar') # => 'FOO_BAR' stringcase.constcase('_bar_baz') # => '_BAR_BAZ' stringcase.constcase('.bar_baz') # => '_BAR_BAZ' stringcase.constcase('') # => '' stringcase.constcase(None) # => 'NONE' ``` -------------------------------- ### Sentence Case Conversion Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string to sentence case, where the first letter is capitalized and words are separated by spaces. ```APIDOC ## Sentence Case Conversion ### Description Converts a string into sentence case where the first letter is capitalized and words are separated by spaces with all other letters in lowercase. ### Method `stringcase.sentencecase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.sentencecase('fooBar') ``` ### Response #### Success Response (200) - **string** - The converted string in sentence case. #### Response Example ``` 'Foo bar' ``` ``` -------------------------------- ### snakecase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string into snake case where all letters are lowercase and words are separated by underscores. ```APIDOC ## snakecase ### Description Converts a string into snake case where all letters are lowercase and words are separated by underscores. This format is commonly used in Python for variable and function names. ### Method `stringcase.snakecase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase # Convert to snake_case stringcase.snakecase('fooBar') stringcase.snakecase('foo_bar') stringcase.snakecase('foo-bar') stringcase.snakecase('foo.bar') stringcase.snakecase('_bar_baz') stringcase.snakecase('.bar_baz') stringcase.snakecase('') stringcase.snakecase(None) ``` ### Response #### Success Response (200) Returns the snake-cased string. #### Response Example ``` 'foo_bar' 'foo_bar' 'foo_bar' 'foo_bar' '_bar_baz' '_bar_baz' '' 'none' ``` ``` -------------------------------- ### Trim whitespace Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Removes leading and trailing whitespace from a string. ```python import stringcase # Trim whitespace stringcase.trimcase(' foo bar baz ') # => 'foo bar baz' stringcase.trimcase(' hello ') # => 'hello' stringcase.trimcase('') # => '' ``` -------------------------------- ### Dot Case Conversion Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string to dot case, where words are separated by periods. ```APIDOC ## Dot Case Conversion ### Description Converts a string into dot case where words are separated by periods. This format is commonly used in package names and configuration keys. ### Method `stringcase.dotcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.dotcase('fooBar') ``` ### Response #### Success Response (200) - **string** - The converted string in dot case. #### Response Example ``` 'foo.bar' ``` ``` -------------------------------- ### Backslash Case Conversion Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Converts a string to backslash case, where words are separated by backslashes. ```APIDOC ## Backslash Case Conversion ### Description Converts a string into backslash case where words are separated by backslashes. This is useful for Windows-style file paths. ### Method `stringcase.backslashcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.backslashcase('fooBar') ``` ### Response #### Success Response (200) - **string** - The converted string in backslash case. #### Response Example ``` 'foo\\bar' ``` ``` -------------------------------- ### Convert to alphanumcase Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Removes all non-alphanumeric characters from a string. ```python import stringcase # Keep only alphanumeric characters stringcase.alphanumcase('_Foo., Bar') # => 'FooBar' stringcase.alphanumcase('Foo_123 Bar!') # => 'Foo123Bar' stringcase.alphanumcase('hello@world') # => 'helloworld' stringcase.alphanumcase('') # => '' stringcase.alphanumcase(None) # => 'None' ``` -------------------------------- ### Alphanumeric Case Conversion Source: https://context7.com/okunishinishi/python-stringcase/llms.txt Removes all non-alphanumeric characters from a string. ```APIDOC ## Alphanumeric Case Conversion ### Description Removes all non-alphanumeric characters from a string, keeping only letters (a-z, A-Z) and digits (0-9). ### Method `stringcase.alphanumcase(input_string)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python import stringcase stringcase.alphanumcase('_Foo., Bar') ``` ### Response #### Success Response (200) - **string** - The string containing only alphanumeric characters. #### Response Example ``` 'FooBar' ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.