function slugify(string:String):String{ const pattern1:RegExp = /[^\w- ]/g; // Matches anything except word characters, space and - const pattern2:RegExp = / +/g; // Matches one or more space characters var s:String = string; return s.replace(pattern1, "").replace(pattern2, "-").toLowerCase();} Report this snippet