The important thing is that there is no NEED to write a new method to split a Smalltalk identifier into pieces, because there already *IS* such a method.
Only write a new method if the existing one doesn't actually work for you. For example, what do you want to be done with strings or symbols that contain non-alphanumeric characters, like #== ? What do you want done with underscores and digits in strings like 'INTL_61_123_456'? On Wed, 26 Oct 2022 at 22:41, Richard O'Keefe <rao...@gmail.com> wrote: > What's wrong with > > $- join: (s cutCamelCase collect: [ :each | each asLowercase]) > > where s is the string you want to transform? > I'm sure you're aware of the proverb: > You have a problem and you decide to solve it with > a regular expression. Now you have TWO problems. > > MYWeirdName and MyWeirdName both map to my-weird-name, > but perhaps you are happy with that. > > On Sat, 22 Oct 2022 at 21:57, Siemen Baader <siemenbaa...@gmail.com> > wrote: > >> Hi, >> >> I'm looking for an elegant way to convert class names with optional >> namespace prefixes to names for custom html elements. >> >> MYCustomElement and CustomElement >> >> to >> <my-custom-element> and <custom-element> >> >> There must be an elegant way to do it with regex or inject, but I'm >> embarrassed to say I can't get my head around it. I can get it to match the >> regex '((:isUppercase:+)*)((:isUppercase::isLowercase:+)*)', (if I recall >> correctly) but can't get a collection of the individual elements 'MY' >> 'Custom" 'Element' to lowercase and join. >> >> Thanks for any hints! >> >> cheers >> Siemen >> >