Some text processing for ruby, not very general