This discussion is archived
1 Reply Latest reply: Nov 13, 2012 2:15 AM by user243865 RSS

join, the reverse of split?

user243865 Newbie
Currently Being Moderated
Hi,

doing split on a string is easy in express... and you get an array as a result...
but there doesn't seem to be a corresponding join where you can add an array of string with a specific string as separator.

So, I should use concat... probably in combination with dolist

but there doesn't seem to be a good join functionality, the join tjat I can call adds spaces and cant be varied it seems

how would you recommend to emulate the normal join in xpress?
  • 1. Re: join, the reverse of split?
    user243865 Newbie
    Currently Being Moderated
    Replying to my own post then....

    Got it to work, finally :-D

    given an array, derived from the users view and some properties on each account...

    pwsafeNames
    <List>
      <String>Lighthouse</String>
      <String>AD</String>
      <String>AD|2</String>
    </List>
    it builds a nice regular expression for my selectall checkbox :D
      <String>^resourceAccounts\\..+\\[(Lighthouse|AD|AD\\|2)]\\.selected$</String>
    with the following code...
    <concat>
      &lt;s>^resourceAccounts\\..+</s>
      <cond>
        <gt>
          <length>
            <ref>pwsafeNames</ref>
          </length>
          &lt;i>0</i>
        </gt>
        <block>
          <set name='fixed'>
            <dolist name='pwname'>
              <ref>pwsafeNames</ref>
              <cond>
                <contains>
                  <ref>pwname</ref>
                  &lt;s>|</s>
                </contains>
                <block>
                  <concat>
                    <get>
                      <split>
                        <ref>pwname</ref>
                        &lt;s>|</s>
                      </split>
                      &lt;i>0</i>
                    </get>
                    &lt;s>\\|</s>
                    <get>
                      <split>
                        <ref>pwname</ref>
                        &lt;s>|</s>
                      </split>
                      &lt;i>1</i>
                    </get>
                  </concat>
                </block>
                <ref>pwname</ref>
              </cond>
            </dolist>
          </set>
          <set name='pwarrsize'>
            <length>
              <ref>fixed</ref>
            </length>
          </set>
          <cond>
            <gt>
              <ref>pwarrsize</ref>
              &lt;i>0</i>
            </gt>
            <block>
              <set name='str'>
                <concat>
                  &lt;s>\\[(</s>
                  <get>
                    <ref>fixed</ref>
                    &lt;i>0</i>
                  </get>
                </concat>
              </set>
              <set name='counter'>
                &lt;i>1</i>
              </set>
              <while>
                <gt>
                  <ref>pwarrsize</ref>
                  <ref>counter</ref>
                </gt>
                <block>
                  <set name='str'>
                    <concat>
                      <ref>str</ref>
                      &lt;s>|</s>
                      <get>
                        <ref>fixed</ref>
                        <ref>counter</ref>
                      </get>
                    </concat>
                  </set>
                  <set name='counter'>
                    <add>
                      <ref>counter</ref>
                      &lt;i>1</i>
                    </add>
                  </set>
                </block>
              </while>
              <set name='str'>
                <concat>
                  <ref>str</ref>
                  &lt;s>)]</s>
                </concat>
              </set>
            </block>
            <set name='str'>
              <concat>
                &lt;s></s>
              </concat>
            </set>
          </cond>
          <ref>str</ref>
        </block>
      </cond>
      &lt;s>\\.selected$</s>
    </concat>
    To bad this forums code tag cant handle &lt;s> and &lt;i> tags, need to replace all &lt; with &amp;lt;
    Edited by: Dhurgan on Nov 13, 2012 11:09 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points