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
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?
What happened?
test_foo_barWhat did I expect?
test-foo_bar