My feeling is that it cannot be solved by regular expressions. The reason it that there is the regular expressions in smalltalk/pharo does not have look-ahead or backtracking. In your example the capital Y is part of MY, but C starts a new word. I do not know of anyway to express that in smalltalk regular expressions.
So I believe this is one of the cases where you add an extension method to string which does the job using plain coding. Best, Kasper > On 22 Oct 2022, at 10.56, 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