Loading ...
Sorry, an error occurred while loading the content.

Re: [NTO] Address the words before the 1st semicolon

Expand Messages
  • Alec Burgess
    Roy: From your description and example, nothing after the first semi-colon is changed so this appears to work: H= First Last Middle ; Alec Burgess 2004-12-21 ;
    Message 1 of 5 , Dec 20, 2004
    • 0 Attachment
      Roy:

      From your description and example, nothing after the first semi-colon is
      changed so this appears to work:

      H= First Last Middle
      ; Alec Burgess 2004-12-21
      ; change "word1 word 2; anything" to "word2 word1; samething"
      ; and then "word1 middle word 2; anything" to "word2 word1 middle;
      samething"
      ^!replace "^{\W+}\s{\W+};" >> "\2 \1;" rwsa
      ^!replace "^{\W+}\s{\W+}\s{\W+};" >> "\3 \1 \2;" rwsa

      note: upper case \W+ finds any non-delimiter string so it stops before the
      space or semicolon.


      Regards ... Alec
      --


      ---- Original Message ----
      From: "Roy Herring" <roynancy@...>
      To: <ntb-OffTopic@yahoogroups.com>
      Sent: Monday, December 20, 2004 17:51
      Subject: [gla: [NTO] Address the words before the 1st
      semicolon

      > I have 2 types of lines in a file. One w/ 4 semicolons
      > and one w/ 3 semicolons.
      > I want to move the last word before the 1st semicolon to
      > the beginning of the line in both cases.
      >
      > The heart of the problem seems to be able to address the
      > words before the 1st semicolon in a line of variable
      > semicolons.
      >
      > Can anyone help?
      > Thanks, Roy
      >
      > Input:
      > First Last; Words2; Words3; Words4;
      > First Middle Last; Words2; Words3;
      >
      > Desired output:
      > Last First; Words2; Words3; Words4;
      > Last First Middle; Words2; Words3;
      >
      > The following works for a line of 4 semicolons
      > ^!REPLACE "^{.+}\s{\B*};{.+;.+;.+;}" >> "\2 \1;\3" rwsati
      >
      > The following works for a line of 3 semicolons
      > ^!REPLACE "^{.+}\s{\B*};{.+;.+;}$" >> "\2 \1;\3" rwsati
      >
      > Together they do not work for both types of lines.
      >
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >
      >
      >
      >
      > ------------------------ Yahoo! Groups Sponsor
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
    • Roy Herring
      Thank you Alec and Don. Don, I was hoping for a regular expression solution but not sure I can do it. If not, I ll use yours. Alec, I probably should have
      Message 2 of 5 , Dec 21, 2004
      • 0 Attachment
        Thank you Alec and Don.

        Don, I was hoping for a regular expression solution but not sure I can do it. If not, I'll use yours.

        Alec, I probably should have given you the real-life data instead of trying to simplify it.
        Can you change your solution to fit this data? I am trying to.

        Thanks again,
        Roy

        The data is mailing addresses, some (like the middle one) have 4 fields of data.
        By putting the last name first, I will be able to sort and then put it back like it was (assuming
        that if I figure out how to put the last name first, I'll be able to put it back later).
        I already have a regex clip to format the semicolon lines to multiple lines for mailing.

        Input:
        Becky & Kevin McClellan;207 Slattery;New Orleans, LA 70105;
        Jeri & John Mazur;Sarah, Michael & Joe;555 Ockley;New Orleans, LA 70105;
        Nancy McInnis;510 Longleaf;New Orleans, LA 70105;

        Desired output:
        McClellan Becky & Kevin;207 Slattery;New Orleans, LA 70105;
        Mazur Jeri & John;Sarah, Michael & Joe;555 Ockley;New Orleans, LA 70105;
        McInnis Nancy;510 Longleaf;New Orleans, LA 70105;


        [Non-text portions of this message have been removed]
      • Alec Burgess
        Roy: I was going to add one additional replace line for each possible extra word in the full name string before the first semicolon, but ampersand also gets
        Message 3 of 5 , Dec 21, 2004
        • 0 Attachment
          Roy:

          I was going to add one additional replace line for each possible extra
          "word" in the full name string before the first semicolon, but ampersand
          also gets treated as a word delimiter when I realized all I have to do is
          find the LAST word string before the FIRST semicolon ... so ...

          H=First Last Middle
          ; Alec Burgess 2004-12-21-b
          ; SOL-notSemicolon_string-space-last_name-semicolon-anything
          ; to --> last_name-space-notSemicolon_string-semicolon-anything
          ^!replace "^{[^\;]+}\s{\W+}\;" >> "\2 \1;" rwsa

          I think this works :-)

          Regards ... Alec
          --


          ---- Original Message ----
          From: "Roy Herring" <roynancy@...>
          To: <ntb-OffTopic@yahoogroups.com>
          Sent: Tuesday, December 21, 2004 15:03
          Subject: [gla: Re: [NTO] Address the words before the 1st
          semicolon

          > Thank you Alec and Don.
          >
          > Don, I was hoping for a regular expression solution but
          > not sure I can do it. If not, I'll use yours.
          >
          > Alec, I probably should have given you the real-life data
          > instead of trying to simplify it.
          > Can you change your solution to fit this data? I am
          > trying to.
          >
          > Thanks again,
          > Roy
          >
          > The data is mailing addresses, some (like the middle one)
          > have 4 fields of data.
          > By putting the last name first, I will be able to sort
          > and then put it back like it was (assuming that if I
          > figure out how to put the last name first, I'll be able
          > to put it back later).
          > I already have a regex clip to format the semicolon lines
          > to multiple lines for mailing.
          >
          > Input:
          > Becky & Kevin McClellan;207 Slattery;New Orleans, LA
          > 70105;
          > Jeri & John Mazur;Sarah, Michael & Joe;555 Ockley;New
          > Orleans, LA 70105;
          > Nancy McInnis;510 Longleaf;New Orleans, LA 70105;
          >
          > Desired output:
          > McClellan Becky & Kevin;207 Slattery;New Orleans, LA
          > 70105;
          > Mazur Jeri & John;Sarah, Michael & Joe;555 Ockley;New
          > Orleans, LA 70105;
          > McInnis Nancy;510 Longleaf;New Orleans, LA 70105;
          >
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >
          > ------------------------ Yahoo! Groups Sponsor
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
        • hsavage
          ... fields of data. ... it back like it was (assuming ... put it back later). ... lines for mailing. ... Roy, I made a ^!Replace command line that works on the
          Message 4 of 5 , Dec 21, 2004
          • 0 Attachment
            Roy Herring wrote:
            > Thank you Alec and Don.
            >
            > The data is mailing addresses, some (like the middle one) have 4
            fields of data.
            > By putting the last name first, I will be able to sort and then put
            it back like it was (assuming
            > that if I figure out how to put the last name first, I'll be able to
            put it back later).
            > I already have a regex clip to format the semicolon lines to multiple
            lines for mailing.
            >
            > Input:
            > Becky & Kevin McClellan;207 Slattery;New Orleans, LA 70105;
            > Jeri & John Mazur;Sarah, Michael & Joe;555 Ockley;New Orleans, LA 70105;
            > Nancy McInnis;510 Longleaf;New Orleans, LA 70105;
            >
            > Desired output:
            > McClellan Becky & Kevin;207 Slattery;New Orleans, LA 70105;
            > Mazur Jeri & John;Sarah, Michael & Joe;555 Ockley;New Orleans, LA 70105;
            > McInnis Nancy;510 Longleaf;New Orleans, LA 70105;

            Roy,

            I made a ^!Replace command line that works on the names up to the first
            semi-colon. It works on the 3 samples you sent, above.

            It should work on everything you have as long as there are no names
            formatted differently than the Input: samples you sent.

            This is the output, I added a comma between the Last, First etc.. If
            you prefer not to have the comma just delete it from the replace side of
            the command.

            McClellan, Becky & Kevin;207 Slattery;New Orleans, LA 70105;
            Mazur, Jeri & John;Sarah, Michael & Joe;555 Ockley;New Orleans, LA 70105;
            McInnis, Nancy;510 Longleaf;New Orleans, LA 70105;

            This is the replace command.

            ^!Replace
            (^{[A-Za-z]+\s&\s[A-Za-z]+}{\s}{[A-Za-z]+}{;})|(^{[A-Za-z]+}{\s}{[A-Za-z]+}{;})
            >> \3,\2\1\4 TIRSa

            I know this is going to get wrapped in email so, there are no spaces in
            the left/find side of the command.

            You can run this as is and it will operate from the cursor position
            downward. If you add 'W' to the options, as, TIWRSA, it will do the
            'W'hole document.

            ºvº
            04.12.21
            hrs > hsavage@...
          • Roy Herring
            Thank you Alec and HRS. Alec, that is EXACTLY what I was looking for. To be able to match to 1st semicolon, ignoring the rest. HRS, your or opens up a lot
            Message 5 of 5 , Dec 21, 2004
            • 0 Attachment
              Thank you Alec and HRS.

              Alec, that is EXACTLY what I was looking for. To be able to match to 1st semicolon, ignoring the rest.
              HRS, your 'or' opens up a lot of possibilities to handle differently formatted lines.

              Thank you both,
              Roy


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.