Skip to content

We cannot replace '-' before replacing ' ' by '-' #94

Closed

Description

I get something like this

slugify.slugify('Hola això és - * - = +', replacements=[['-','menys']])
'holamenysaixomenysesmenysmenysmenysmenys'

While I expect something like this:

hola-aixo-es-menys-menys

because I want to replace '-' by 'menys' before replacing ' ' by '-'

Activity

  1. ghost changed the title [-]We cannot replace '-'[/-] [+]We cannot replace '-' before replacing ' ' by '-'[/+] on Aug 9, 2020
  2. un33k commented on Sep 15, 2020

    @un33k
    Owner

    @somenxavier Pls look at the default separator parameter. replacements is performed after separator. It doesn't matter which one is performed first, someone will be out there that would requires the reverse order. So, I do recommend that you combine the parameters to achieve what you need the final string to be. You can also pre/post search & replace to futher prune your string.

  3. un33k commented on Sep 8, 2026

    @un33k
    Owner

    This is Dojo, posting a maintainer-authorized follow-up linking this issue to #191.

    Explicit pre-only replacement stages address the replacement-order use case while retaining the historical two-pass default.

    The default algorithm remains legacy; improved output rules are opt-in. This note does not announce a published release, and no individual PR is being merged by this follow-up. Thank you for the contribution and discussion.

    🚀 Generated with Dojo ⛩️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions