Re: A repost - Permuting SPACES within a String of words
From: ole Michelsen (imom_at_pop.dtu.dk)
Date: 02/03/05
- Next message: Israel Moreno: "Problems with excel"
- Previous message: Markus Scheible: "Filling Series of columns with Dates"
- In reply to: Hari Prasadh: "A repost - Permuting SPACES within a String of words"
- Next in thread: Hari Prasadh: "Re: A repost - Permuting SPACES within a String of words"
- Reply: Hari Prasadh: "Re: A repost - Permuting SPACES within a String of words"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 3 Feb 2005 16:25:03 +0100
You should use the split function to separate the words.
array=split(string," ")
Then you should check for empty cells array
aray(n)=""
Use ubound to find out how many cells your array contains
Then you can construc your permutations by concatanating the words
newstring= array(0) & " " & array(1) & ............
You should be able to do this by some looping codes
Ole Michelsen
"Hari Prasadh" <excel_hariNOSPAM@hotSPAREMEmail.com> wrote in message
news:%23fAfeEgCFHA.444@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I posted this problem around 3-4 days back.....I have tried to paraphrase
> the problem in a probably simpler way below.
>
> I want to generate permutations of a string made up of 2 or more words in
> such a way that I get outputs :
>
> a) where there is no space between any of the words in the string
> b) Where there is only one space between any 2 words in the string.
> c) where there is a single space between some of the letters in the string
> but rest words dont have any space between them. And do this process for
> all possible permutations.
>
> I have got solutions to a) and b) by swiping from previous posts. ( Split
> array method )
>
> It's the c) which is..
>
> For example if I have a string in Cells(1,1) having the value -- I went
> to Paris --
>
> the answer for a) will be -- IwenttoParis --
> the answer for b) will be -- I went to Paris -- Basically, b) will be same
> as the original string.
>
> the answer(s) for c) would be
> i) Iwentto Paris
> ii) I wenttoParis
> iii) Iwent toParis
> iv) Iwent to Paris
> v) I went toParis
> vi) I wentto Paris
>
> Explanation - of part c) :
> In parts i) and ii) 3 of the words in the string have been combined
> together and the lone word is separated by a single space.
>
> In part iii) 2 sets of adjacent words have been combined together and
> there is a single space between these 2 set.
>
> In parts iv), v) and vi) ONLY one set of adjacent words have been combined
> together and there is a single space between any 2 words.
>
> How to effect the above combinations... in view of the fact that number of
> words in the string (Cells(1,1)) would be variable.
>
> Thanks a lot,
> Hari
> India
>
- Next message: Israel Moreno: "Problems with excel"
- Previous message: Markus Scheible: "Filling Series of columns with Dates"
- In reply to: Hari Prasadh: "A repost - Permuting SPACES within a String of words"
- Next in thread: Hari Prasadh: "Re: A repost - Permuting SPACES within a String of words"
- Reply: Hari Prasadh: "Re: A repost - Permuting SPACES within a String of words"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|