Hope you can help a bit of an Autohotkey Noob here.
Here is what I would like to do.
1) Manually highlight some text
2) Press a function key eg F1
3) Run the follow regex on the highlighted text and return the results to the clipboard
The function/regex that I need to run is this. Basically it turns the text into a url friendly "slug". I can use this in js but I have no idea how to do this in Autokey.
Code: Select all
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}