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
>

Reply via email to