🛠️ToolsShed

ケース変換

テキストをUPPERCASE、lowercase、Title Case、camelCaseなどに変換。

UPPERCASE

ここに結果が表示されます...

lowercase

ここに結果が表示されます...

Title Case

ここに結果が表示されます...

Sentence case

ここに結果が表示されます...

camelCase

ここに結果が表示されます...

snake_case

ここに結果が表示されます...

kebab-case

ここに結果が表示されます...

aLtErNaTiNg

ここに結果が表示されます...

ケースコンバーターはテキストをさまざまな文字ケース形式に瞬時に変換します。見出しのUPPERCASE、メールアドレスのlowercase、書籍タイトルのTitle Case、またはプログラミング変数名のcamelCaseなど、すべての一般的なケース変換をサポートします。

テキストを貼り付けて目的の出力形式を選択します。UPPER CASE、lower case、Title Case、Sentence case、camelCase、PascalCase、snake_case、kebab-caseがサポートされています。

ケース変換はプログラミングワークフローで特に役立ちます。JavaScriptは変数にcamelCase、Pythonはsnake_case、CSSはkebab-case、ほとんどのオブジェクト指向言語はクラス名にPascalCaseを使用します。

よくある質問

コード実装

import re

def to_words(text: str) -> list[str]:
    """Split text into words, handling camelCase, snake_case, kebab-case, and spaces."""
    text = re.sub(r"([a-z])([A-Z])", r"\1 \2", text)  # camelCase split
    text = re.sub(r"[_\-]+", " ", text)                  # snake/kebab to space
    return [w for w in text.strip().split() if w]

def to_camel_case(text: str) -> str:
    words = to_words(text)
    return words[0].lower() + "".join(w.capitalize() for w in words[1:])

def to_pascal_case(text: str) -> str:
    return "".join(w.capitalize() for w in to_words(text))

def to_snake_case(text: str) -> str:
    return "_".join(w.lower() for w in to_words(text))

def to_kebab_case(text: str) -> str:
    return "-".join(w.lower() for w in to_words(text))

def to_screaming_snake(text: str) -> str:
    return "_".join(w.upper() for w in to_words(text))

# Example usage
text = "hello world example"
print(to_camel_case(text))      # helloWorldExample
print(to_pascal_case(text))     # HelloWorldExample
print(to_snake_case(text))      # hello_world_example
print(to_kebab_case(text))      # hello-world-example
print(to_screaming_snake(text)) # HELLO_WORLD_EXAMPLE

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.