blob: 656f65fbc0e85d99fb56c5015ff5fc640f541647 [file] [log] [blame]
Vodafone804ec682019-03-18 15:46:53 +05301/*!
2 * Copyright (C) 2019 Vodafone Group.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
15 */
16function unCamelCaseString(message) {
17 return message
18 .replace(/([a-z])([A-Z])/g, '$1 $2')
19 .replace(/\b([A-Z]+)([A-Z])([a-z])/, '$1 $2$3')
20 .replace(/^./, function(str) {
21 return str.toUpperCase();
22 });
23}
24
25let unCamelCasedString = str => {
26 return unCamelCaseString(str);
27};
28
29export default unCamelCasedString;