Fri Jun 12 09:10:21 AM MDT 2026 Today is Friday! (Friyay!) But it feels like they come so slow. It’s sad when you look forward to the weekend. I’m not sure how that ever came on the radar, but that’s what this life feels like at times. I wish I didn’t feel this way most weeks, but that’s how I feel. It would be nice to be able to get over whatever is causing this, but what am I going to do about it? So many questions that don’t have a way of making sense. There is never a way to make sense of it all I suppose, that’s what this life is all about. If I had a way to make the future possible? I would so be on that. I’m not sure how that works though. There needs to be a way to make this life manageable. I doubt there seems to be a way to overcome anything. So many possibilities and thought processes out there, I doubt there is a way to overcome a lot in this life. Fri Jun 12 10:09:44 AM MDT 2026 I wish I could understand what this life is meant to turn out to be! I don’t get it most da...
Sometimes you want a slug to make a filename. A slug is a group of words where the punctuation is removed and spaces are replaced with hyphens.
Here is a simple way to implement this in Java. (It’s met my needs so far.)
/**
* Returns a phrase into a slug ie: This Is Good (this-is-good.md)
* @param input The text to transform into a slug
* @return The slug of the text passed in
*/
public static String toSlug(String input) {
return input
.toLowerCase()
.replaceAll("[^a-z0-9\\s]", "") // remove punctuation
.trim()
.replaceAll("\\s+", "-") // spaces → hyphens
+ ".md";
}
It can use some work. I have noticed if you have a hyphen in the word you pass in, it will put – which you might not want. So yeah some tweaks can be added to it for sure.
Comments
Post a Comment