Text Separation

Hi Team,

How can we separate name and surname combined together like PeterGomes, HarrisDawn and having multiple records. Thanks in advance.  

  • There is not enough info here to discern what you are after.

    • I know your statement sounds simple to you, but what does, for example, 'multiple records' mean in context.?
    • Where is the data coming from?
    • Why can't the source of the data be used to output it in a more standard way
    • How is this data represented. list, rows - comma separated...?

    Lastly, if the data you show is always in this fashion, then the only possibility I can think of off the top of my head is you have to use RegEx case sensitive matching to split this.

    So, using the two names you show here:


        # Crete a names array and split on TitleCase, with a lead space for the user name pair.
        ($NamesArray = 'PeterGomes', 'HarrisDawn' | %{"`n";[regex]::Split($_,'(?<!^)(?=[A-Z])')})

        Peter
        Gomes


        Harris
        Dawn

    Or this...

        ($NamesArray = 'PeterGomes', 'HarrisDawn' | %{[regex]::Split($_,'(?<!^)(?=[A-Z])') -join ','})

        Peter,Gomes
        Harris,Dawn

    Or this...

        ($NamesArray = 'PeterGomes', 'HarrisDawn' | %{[regex]::Split($_,'(?<!^)(?=[A-Z])') -join ','}) | ConvertFrom-Csv -Header FirstName,LastName

        FirstName LastName
        --------- --------
        Peter     Gomes  
        Harris    Dawn 

    However, as you can see, this just kicks out as a list / formatted table from that string array that I had to manually create.
    So, without knowing your full deal here. Meaning what you are trying to do. You'd now have to put this back together in some usable form for your needs.

  • The most ideal tool for the activity here is recursion, not customary articulations. The essential thought is to begin from the earliest starting point of the string searching for a word, at that point take the rest of the string and search for another word, etc until the finish of the string is come to. A recursive arrangement is normal since backtracking needs to happen when a given rest of the string can't be broken into an arrangement of words.

    essay dune