Skip to content

Question/Bug: how do I preserve dashes and not replace them with separator? #107

Description

@adamcunnington-mlg

I am trying to slugify a string, replacing non-matching characters with an underscore, but I don't want to consider a dash a non-matching character. This is easily achieved with regex but it looks like there is some special slugify behaviour when it comes to dashes which is preventing this working. I can't see anything in the docs or code, about how to work around this.

What did I do?

slugify.slugify("test-foo bar", separator='_', regex_pattern=r'[^-a-zA-Z0-9_]+')

What happened?
test_foo_bar

What did I expect?
test-foo_bar

Activity

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