blakeembrey / change-case

Convert strings between camelCase, PascalCase, Capital Case, snake_case and more
MIT License
2.22k stars 92 forks source link

capitalCase when single number #276

Closed taylorjohnson141 closed 2 years ago

taylorjohnson141 commented 2 years ago

Trying to accomplish the below and having trouble with 1Day part. e.g. SomeThingIn1Day => Some Thing In 1 Day

Tried regexp: ([a-z0-9])([A-Z0-9])

Works OK if the number is 2 digits (more than 2 would have issue with the regexp above).

blakeembrey commented 2 years ago

You'll probably need multiple splits as array, here's an example: https://runkit.com/blakeembrey/617617d85eff590008805e9c.

Main gist:

capitalCase('SomeThingIn1Day', { splitRegexp: [/([a-z])([A-Z0-9])/g, /([0-9])([A-Z])/g] });