Capitalize only in specified columns

Capitalize only in specified columns

3
NewbieNewbie
3

    Oct 10, 2005#1

    Hi,
    I've got 2 questions regarding regular expression.
    The first is:

    How can I transform a text like
    asdfgh qwertz
    sdfgerfhhjkjk dhgkjdk

    to
    Asdfgh Qwertz
    Sdfgerfhhjkjk Dhgkjdk
    (The first letter after a blank should become a capital)

    The second question is:

    How can I transform the text
    qwert-asdfg
    asdfgh - sjhdfgshf

    to
    asdfg-qwert
    sjhdfgshf - asdfgh
    (Exchanging the two sides of '-')

    Any help would be greatly appreciated :-)
    Regards from Vienna as well :-)

    HolySpirit

    206
    MasterMaster
    206

      Oct 10, 2005#2

      Question 1. A macro solution, will be slow on a large file. Make sure you have an empty line at the end of the file, or it won't know when to stop. It upper cases the first character in each line and the first character following each space.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOn
      Top
      ToUpper
      Loop
      Key DOWN ARROW
      IfEof
      ExitLoop
      EndIf
      ToUpper
      EndLoop
      Top
      Loop
      Find " "
      IfEof
      ExitLoop
      EndIf
      EndSelect
      Key RIGHT ARROW
      Key LEFT ARROW
      ToUpper
      Key HOME
      Key DOWN ARROW
      EndLoop


      Question 2. a regex search and replace - fast

      Regular Expressions checked
      Unix-style regular expressions (see configuration)

      Find What: (.+)( *)-( *)(.+)
      Replace With: \4\2-\3\1
      Software For Metalworking
      http://closetolerancesoftware.com

      3
      NewbieNewbie
      3

        Oct 11, 2005#3

        Thank you, it worked fine, but I've got to precise my question :oops: .

        For both cases:
        Search-replace should occur only for the marked columns :oops:

        Best regards from Vienna
        Holy Spirit

        206
        MasterMaster
        206

          Oct 11, 2005#4

          You'll have to furnish truly representative before/after samples before anybody can help.
          Software For Metalworking
          http://closetolerancesoftware.com

          3
          NewbieNewbie
          3

            Oct 11, 2005#5

            Ok, sorry for that :oops:

            The text
            aaaaaaaaaaaa asdfgh qwertz
            aaaaaaaaaaaa sdfgerfhhjkjk dhgkjdk

            should be transformed to


            aaaaaaaaaaaa Asdfgh Qwertz
            aaaaaaaaaaaa Sdfgerfhhjkjk Dhgkjdk

            And the text

            aaaaaaaaaaaa qwert-asdfg
            aaaaaaaaaaaa asdfgh - sjhdfgshf

            to
            aaaaaaaaaaaa asdfg-qwert
            aaaaaaaaaaaa sjhdfgshf - asdfgh
            (Exchanging the two sides of '-')

            Thanks a lot in advance
            Best regards
            Holy Spirit

            206
            MasterMaster
            206

              Oct 11, 2005#6

              Try these.

              Question 1.

              InsertMode
              ColumnModeOff
              HexOff
              UnixReOn
              Top
              Loop
              Find RegExp "^[a]+ [a-z]"
              IfNotFound
              ExitLoop
              EndIf
              EndSelect
              Key LEFT ARROW
              ToUpper
              Find " "
              EndSelect
              Key RIGHT ARROW
              Key LEFT ARROW
              ToUpper
              EndLoop



              Question 2.

              Regular Expressions checked
              Unix-style regular expressions (see configuration)

              For some reason it doesn't change the first line. Open up a blank line at the top of your file before the search/replace. Also have a blank line at the end.


              Find What: (^[a]+ )(.+)( *)-( *)(.+)
              Replace With:\1\5\3-\4\2
              Software For Metalworking
              http://closetolerancesoftware.com