LoginSignup
7
5

More than 5 years have passed since last update.

Pythonでキャメルケースの文字列を単語ごとに分割

Last updated at Posted at 2014-06-02

キャメルケースの文字列を単語ごとに分割する


import re
str = 'getSampleTextFromDB'
[x for x in re.split('([a-z]+)([A-Z][a-z]+)|([A-Z][a-z]+)', str) if x != None and x != '']

実行結果


['get', 'Sample', 'Text', 'From', 'DB']
7
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
5