Tapatalk

Need help with "-"

Need help with "-"

4
NewbieNewbie
4

    Sep 07, 2006#1

    Hi guyz
    lets say i have this line

    hello my name is kim-sam-soon
    from that line. how do i extract "kim-sam-soon" using a macro without selecting the whole line?

    i just want that phrase.
    any ideas? thx in advance

    344
    MasterMaster
    344

      Sep 07, 2006#2

      Hi man,

      do a perl regexp search like this:

      PerlReOn
      Find RegExp "[a-z]*\-[a-z]*\-[a-z]*"

      It looks for some SMALL letters with 2 minus signs in between.

      rds Bego
      Normally using all newest english version incl. each hotfix. Win 10 64 bit

      4
      NewbieNewbie
      4

        Sep 07, 2006#3

        erm the thing is
        the number of -'s is not fixed..a ny way to go around it?

        344
        MasterMaster
        344

          Sep 07, 2006#4

          erm, this make thinks look harder.
          The problem is, that you cant say: [a-z-]+ because it also hits words without minus ....
          Well, the only soultion I find looks like this and finds up to words with 4 minus signs (you can easily extend this) including the spaces before and after to identify that word as a whole. I use the "or" condition (concatenated |).
          Maybe so else finds a better algorithm:

          EDITED: \w as a word-character is better
          (\s\w*\-\w*\s|\s\w*\-\w*\-\w*\s|\s\w*\-\w*\-\w*\-\w*\s|\s\w*\-\w*\-\w*\-\w*\-\w*\s)

          rds Bego
          Normally using all newest english version incl. each hotfix. Win 10 64 bit

          4
          NewbieNewbie
          4

            Sep 07, 2006#5

            erm..
            hey.. i tried it... but it looks like it cannot work.. i used this:

            InsertMode
            ColumnModeOff
            HexOff
            UnixReOff
            Find RegExp "[a-z]*\-[a-z]*\-[a-z]*"

            is the syntax alright?

            344
            MasterMaster
            344

              Sep 07, 2006#6

              you have to explicitly say: PerlReOn instead of UnixReOff
              You need UE 12, best: 12.10a, not b
              Normally using all newest english version incl. each hotfix. Win 10 64 bit

              4
              NewbieNewbie
              4

                Sep 07, 2006#7

                i am using the version 12.10b.. and i changed the codes to this

                InsertMode
                ColumnModeOff
                HexOff
                PerlReOn
                Find RegExp "[a-z]*\-[a-z]*\-[a-z]*"

                the testing code i am using is this:
                Welcome to my-life-friend

                but i am still not able to get it highlighted

                344
                MasterMaster
                344

                  Re: Need help with "-"

                  Sep 07, 2006#8

                  It won't work when your file ends with your example line.
                  You need at least one carriage-return.
                  Or look also here, it depends on the match-case-settings(!): Perl RegExs misbehaving in v12.10b

                  I use 12.10a and this (multi-line) example.
                  Try it out and report. If it does not work, it's a 12.10b bug.
                  See in the forum for that.

                  Code: Select all

                  lalala das ist ein test-mit vielen Strichen
                  lalala das ist ein-test-mit vielen Strichen
                  lalala das ist ein-test-mit-vielen Strichen
                  lalala das ist ein-test-mit-vielen-Strichen
                  EDIT: IT IS A 12.10b bug. Go back to a.
                  Normally using all newest english version incl. each hotfix. Win 10 64 bit

                  6,685587
                  Grand MasterGrand Master
                  6,685587

                    Sep 07, 2006#9

                    Forget the Perl engine with v12.10b. Use the UltraEdit engine:

                    InsertMode
                    ColumnModeOff
                    HexOff
                    UnixReOff
                    Find RegExp "[a-z]+-[a-z]+-[a-z]+"

                    But maybe following would be better:

                    InsertMode
                    ColumnModeOff
                    HexOff
                    UnixReOff
                    Find RegExp "[a-z^-]+[ ^t]++$"

                    This regular expression simply selects the last "word" (= string which contains only the letter A-Z, a-z or the character '-') on a line with it's trailing spaces, if the line has trailing spaces. It will not work for the last line of the file if it is not terminated with a line termination (CRLF for DOS).

                    See in help of UltraEdit the page about Regular Expressions which of course you should have been already done because I have already suggested to you to read the help about the Find command and at this help page there is also the link to the UltraEdit and Unix regular expressions help. Stop wasting our time because of being too lazy to read in help.
                    Best regards from an UC/UE/UES for Windows user from Austria