Replace Characters for Searching

Hope you're having a great Saturday.

I'm creating a project that I need clean URLs for.

Here's what I mean:

People can create a project with a title. The title can contain letters, numbers, dashes (-), commas, colons, semi-colons, and spaces.

So if I create a project like "Foo: Bar", I don't want the URLs to look like localhost:8888/post/foo%3A%20bar, but instead localhost:8888/post/foo-bar.

Here's what I'm asking:

1) Is it possible to remove a string of special characters (defined above) of any length and replace it with a single dash (-)?

2) Is it possible to then have regex or Javascript that replaces the dash with a wildcard so I can search the MongoDB database for that title?

Thanks a million!

import re
x="foo:bar"
print re.sub("[^a-zA-Z0-9]+","-",x)

This is in python.There is match in java where the same regex can be used. For b) part be you can again use re.sub to replace "-" to any wildcard of your choice.