“Riffle” two strings Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Convenient string manipulationHow to join two Style[]d stringsStyle markers in stringsCounting instances where the two identical characters are at the same positions in two stringsHighlighting or coloring certain words / substrings appearing in a larger stringReversibly abstracting a list of strings as a graph object where vertices represent strings and edge connect pairs of strings based on various testsModifying strings in a list efficientlyHow to extract all sub-strings of string with a specified start and end using StringCases?How to return a default value if no match is found in search of stringHow to count the number of characters seperated by a special character in a string?

Blender game recording at the wrong time

Classification of bundles, Postnikov towers, obstruction theory, local coefficients

Can a zero nonce be safely used with AES-GCM if the key is random and never used again?

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

Slither Like a Snake

What are the performance impacts of 'functional' Rust?

How to colour the US map with Yellow, Green, Red and Blue to minimize the number of states with the colour of Green

How to rotate it perfectly?

Was credit for the black hole image misattributed?

What kind of display is this?

Who can trigger ship-wide alerts in Star Trek?

Why don't the Weasley twins use magic outside of school if the Trace can only find the location of spells cast?

What LEGO pieces have "real-world" functionality?

How should I respond to a player wanting to catch a sword between their hands?

Did the new image of black hole confirm the general theory of relativity?

When is phishing education going too far?

What is the electric potential inside a point charge?

Can a monk deflect thrown melee weapons?

How do you clear the ApexPages.getMessages() collection in a test?

Can smartphones with the same camera sensor have different image quality?

Autumning in love

Two different pronunciation of "понял"

Stop battery usage [Ubuntu 18]

How does modal jazz use chord progressions?



“Riffle” two strings



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Convenient string manipulationHow to join two Style[]d stringsStyle markers in stringsCounting instances where the two identical characters are at the same positions in two stringsHighlighting or coloring certain words / substrings appearing in a larger stringReversibly abstracting a list of strings as a graph object where vertices represent strings and edge connect pairs of strings based on various testsModifying strings in a list efficientlyHow to extract all sub-strings of string with a specified start and end using StringCases?How to return a default value if no match is found in search of stringHow to count the number of characters seperated by a special character in a string?










3












$begingroup$


I have two strings, e.g., s1="A|P|Q|Z" and s2="r|ss|t|yy", where "|" is meant to be a separator. I would like to get the result as another string s=Ar|Pss|Qt|Zyy by joining the corresponding parts of the two strings s1 and s2 as indicated by the separators. What would be a simple way to do this?










share|improve this question









$endgroup$
















    3












    $begingroup$


    I have two strings, e.g., s1="A|P|Q|Z" and s2="r|ss|t|yy", where "|" is meant to be a separator. I would like to get the result as another string s=Ar|Pss|Qt|Zyy by joining the corresponding parts of the two strings s1 and s2 as indicated by the separators. What would be a simple way to do this?










    share|improve this question









    $endgroup$














      3












      3








      3


      1



      $begingroup$


      I have two strings, e.g., s1="A|P|Q|Z" and s2="r|ss|t|yy", where "|" is meant to be a separator. I would like to get the result as another string s=Ar|Pss|Qt|Zyy by joining the corresponding parts of the two strings s1 and s2 as indicated by the separators. What would be a simple way to do this?










      share|improve this question









      $endgroup$




      I have two strings, e.g., s1="A|P|Q|Z" and s2="r|ss|t|yy", where "|" is meant to be a separator. I would like to get the result as another string s=Ar|Pss|Qt|Zyy by joining the corresponding parts of the two strings s1 and s2 as indicated by the separators. What would be a simple way to do this?







      string-manipulation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 9 at 19:37









      nanjunnanjun

      44629




      44629




















          1 Answer
          1






          active

          oldest

          votes


















          8












          $begingroup$

          Try this:



          StringSplit[s1, s2, "|"] // Transpose // StringRiffle[#, "|", ""] &





          share|improve this answer









          $endgroup$












          • $begingroup$
            Clean and elegant (+1).
            $endgroup$
            – David G. Stork
            Apr 9 at 19:53











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "387"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194893%2friffle-two-strings%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8












          $begingroup$

          Try this:



          StringSplit[s1, s2, "|"] // Transpose // StringRiffle[#, "|", ""] &





          share|improve this answer









          $endgroup$












          • $begingroup$
            Clean and elegant (+1).
            $endgroup$
            – David G. Stork
            Apr 9 at 19:53















          8












          $begingroup$

          Try this:



          StringSplit[s1, s2, "|"] // Transpose // StringRiffle[#, "|", ""] &





          share|improve this answer









          $endgroup$












          • $begingroup$
            Clean and elegant (+1).
            $endgroup$
            – David G. Stork
            Apr 9 at 19:53













          8












          8








          8





          $begingroup$

          Try this:



          StringSplit[s1, s2, "|"] // Transpose // StringRiffle[#, "|", ""] &





          share|improve this answer









          $endgroup$



          Try this:



          StringSplit[s1, s2, "|"] // Transpose // StringRiffle[#, "|", ""] &






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 9 at 19:47









          sakrasakra

          2,8031429




          2,8031429











          • $begingroup$
            Clean and elegant (+1).
            $endgroup$
            – David G. Stork
            Apr 9 at 19:53
















          • $begingroup$
            Clean and elegant (+1).
            $endgroup$
            – David G. Stork
            Apr 9 at 19:53















          $begingroup$
          Clean and elegant (+1).
          $endgroup$
          – David G. Stork
          Apr 9 at 19:53




          $begingroup$
          Clean and elegant (+1).
          $endgroup$
          – David G. Stork
          Apr 9 at 19:53

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Mathematica Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194893%2friffle-two-strings%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

          Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

          What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company