Basic javascript text processing utilities