From: Jan Fischer Date: 2008-11-13T19:27:20+09:00 Subject: Re: Regular expression for matching spaced letters needed Sorry, wanted it here. Jan Fischer schrieb: > Hi all, > > please tell me, if this isn't the right place to ask. > 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? > > Regards Jan