[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/yangjun616/algorithm-python2/master/string_to_hump.md [Back]  [Original]

#



border-bottom-color -> borderBottomColor

#

##python
    def convert(one_string,space_character):    #one_string:space_character:

        string_list = str(one_string).split(space_character)    #list
        first = string_list[0].lower()
        others = string_list[1:] 

        others_capital = [word.capitalize() for word in others]      #str.capitalize():

        others_capital[0:0] = [first]

        hump_string = ''.join(others_capital)     #list

        return hump_string

    if __name__=='__main__':
        print "the string is:ab-cd-ef"
        print "convert to hump:"
        print convert("ab-cd-ef","-")
        

##

###racket (racket 5.2.1)

```racket
#lang racket

;  train-to-camel
(define (train-to-camel train-str separator-char)
  (let
    [(splited-str (regexp-split separator-char train-str))]      ;  '-' 
    (string-append
      (first splited-str)
      (apply
        string-append
        (map
          string-titlecase
          (rest splited-str))))))

;  train-to-camel
(train-to-camel "this-is-a-var" "-")  ; ,  "thisIsAVar"

```

--------------

### Ruby 

```ruby
str.split('-').map{|x| x.capitalize}.join
```

```ruby
str = 'border-bottom-color'
str.split('-').map{|x| x.capitalize}.join
# => "BorderBottomColor"
```

### qiwsir#gmail.com (# to @)

Web Proxy Viewer  |  New URL  |  Original Page