MCPcopy Create free account
hub / github.com/cryptii/cryptii / camelCaseToRegular

Method camelCaseToRegular

src/StringUtil.js:18–26  ·  view source on GitHub ↗

* Translates camel case to regular string. * @see https://stackoverflow.com/a/6229124/490161 * @example * let a = StringUtil.camelCaseToRegular('helloWorld') * // returns 'Hello World' * let b = StringUtil.camelCaseToRegular('ILoveYOU') * // returns 'I Love YOU' * @param {string

(string)

Source from the content-addressed store, hash-verified

16 * @return {string}
17 */
18 static camelCaseToRegular (string) {
19 return string
20 // insert a space between lower case & upper case characters
21 .replace(/([a-z])([A-Z])/g, '$1 $2')
22 // space before last upper case in a sequence followed by lower case
23 .replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
24 // uppercase the first character
25 .replace(/^./, first => first.toUpperCase())
26 }
27
28 /**
29 * Returns unique identifier for current session.

Callers 2

StringUtil.jsFile · 0.80
constructorMethod · 0.80

Calls 1

toUpperCaseMethod · 0.80

Tested by

no test coverage detected