Regex

Use

myString.replace(/\s/, "-"); //replaces spaces with dashes

see website for rules and testing environment: regex toolbox http://design215.com/toolbox/regexp.php

 

puts brackets around words with doubled final consonants, then lists the doubled consonant and the suffix /(\b\w+[aeiou] ([bdfglmnprstz])\2 (ing|y|ed|er|en|est) \w* \b)/xig "[$1]:$2:$3"
adds markup to a umd link: /http:\w{1,} \.umd \.edu/gx "<a href=\"$&\">this<\\a>"
soc secy number /(\d{3})\s*(\d{2})\s*(\d{4})/g "$1-$2-$3"
adds zero before decimal /([\s+\-*\/^]-?)\.(\d+)\b/g "$10.$2"
trims trailing zeros /\b(-?\d+\.\d*?)0+\b/g "$1"
removes trailing decimal points (unless they are the last char in string - so add a space first) /\b(-?\d+)\.([\s+\-*\/^])/g "$1$2"