Re: A repost - Permuting SPACES within a String of words

From: ole Michelsen (imom_at_pop.dtu.dk)
Date: 02/03/05


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
>



Relevant Pages

  • Re: Comparing 2 strings for matches in any order
    ... > single space delimiter). ... I need to compare to Column A row 2 and so forth. ... > Then the whole process repeats, matching Column B's bear to the array ... > determine that there was a positive match made for that string in ...
    (microsoft.public.access.modulesdaovba)
  • Re: Remove spaces in CSV file using VB6
    ... using a Byte array instead of a string unless speed is critical (which I ... I am pretty sure that the OP wants to keep the single space between ...
    (microsoft.public.vb.general.discussion)
  • Re: int conversion from char
    ... >> In writing a function that take as it's arguments a string and the length ... I need to change the char input array to an integer array ... Single space? ...
    (comp.lang.c)
  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)