From: Peter Szinek Date: 2008-11-13T20:05:34+09:00 Subject: Re: Regular expression for matching spaced letters needed Hi, >> please tell me, if this isn't the right place to ask. Yeah, it is! :-) >> I am looking for a regular expression which matches "spaced words" >> in a sentence like, for example, "M I L L E R" or "B u s h" and >> replaces them with "Miller" or "Bush". >> I found out that sub!(/\s?([A-Z])\s([A-Z])\s([A-Z])\s([A-Z])\s([A- >> Z])\s?/,' \1\2\3\4\5 ') works for 4 Letters. (Analogue for any >> other fix number.) But I just can't figure out how to match any >> number and how to don't match any letters of surrounding words. >> "A B C D E" -> "ABCDE" >> "a b c d" -> "abcd" >> "hello A B C test" -> "hello ABC test" >> Think you got it. Which regexp will do the job? I would probably use: "A B C D E".split(' ').join HTH, Peter ___ http://www.rubyrailways.com