Converting selected text or text between tags to uppercase

Converting selected text or text between tags to uppercase

6
NewbieNewbie
6

    Sep 30, 2006#1

    I have to change a large group of files and text by converting some code to uppercase based on it matching some criteria. The following is the criteria: I need to change all text following a '->' to uppercase. This will always be 1 word. Below is an example:

    $line->sample_word9 CONVERTED TO $line->SAMPLE_WORD9

    This is due to having to use Oracle now when all my stuff was designed for MySQL. All the object references and such before was based on the actual case of the column in the database, but Oracle makes the object reference all caps no matter what. I have hundreds of pages of code and I'm looking for a regular experession to find all the occurances and change them to uppercase. These will be found all over the code. They won't always be at the begining of a line or at end. Thus I can't base my expression on the beg or end of a line.

    Thanks in advance for any help!

    206
    MasterMaster
    206

      Sep 30, 2006#2

      This macro might do the job.

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

      6
      NewbieNewbie
      6

        Sep 30, 2006#3

        Sorry for sounding noobish, but I've never used macros in UE. How do I go about using them? Thanks for the response!

        206
        MasterMaster
        206

          Sep 30, 2006#4

          • Main Menu - click Macro
          • Edit Macro
          • New Macro
          • give the macro a name
          • check "Continue if a find with replace not found"
          • assign to a hotkey if you want to
          • OK
          • erase the four lines of code that UE generates
          • paste my macro in
          • Close
          • Main Menu - Macro
          • Save All - I use main.mac as my macro filename
          • Main Menu - Macro
          • Play Any/Multiple Times
          • 1
          • OK
          This should get you going - then read about macros in the Help file.

          6
          NewbieNewbie
          6

            Oct 03, 2006#5

            That worked great thanks! I have a few more questions that maybe you can help with:

            1. Is it possiable to run a macro on multiple files at once and if so how?

            2. I want to find a pattern and insert a new line and some text after it. Such as the following:

            $result = oci_parse($query, $conn);

            Would like to turn into:


            $result = oci_query($query, $conn);
            $r = oci_parse($query)

            Where the red text is found and inserted into the line that is added. Not sure how to explain that, so I hope I did ok. The variable will always be differently named but it will always be a '$' followed by a legitimate variable name. Not sure how to insert in a new line so that is the hardest part for me. If I could turn it into a macro even better.

            3. I would like to find any occurrence of the following and delete it. It will be part of a line so i don't want the line deleted only the occurrence. The catch is that it will always have a diff variable name it. So that will have to be claused. It will be any legit variable such as a-z any case 0-9 _ and - That is rep by the red text below and yes that is a space before it. I want to delete all but the ';' since that will be needed to end the line in the code.

            (space)or mysql_error($query);

            Thanks for any help and I hope I described it well enough.

            6,602548
            Grand MasterGrand Master
            6,602548

              Oct 06, 2006#6

              1. See FOR EXAMPLE How do you run a Macro on open files?. Please use forum search before asking. Other solutions also exist. I have posted several solutions for that issue.


              2. You should read the help article about Regular Expressions. In UltraEdit style:

              Find: ^$result = oci_parse(^(^$*^), ^$conn);
              Replace: $result = oci_parse(^1, $conn);^p$r = oci_parse(^1)


              3. Again in UltraEdit style:

              Find: or mysql_error(^$[a-zA-Z0-9_^-]+);
              Replace:

              6
              NewbieNewbie
              6

                Oct 12, 2006#7

                I shall read up on the those 2 things. Thank you for pointing me in the right directions.

                Those worked great with some modifications. I read up on the UEdit form of Reg Exp and it helped alot. This whole time I thought it used hte Unix way by default...thus some of my problems. Thank you for the help and pointing me to the help sources.

                Not sure if it will help anyone else but here is the final ones I used (disreguard the '' as I use them to just encase the statements so I know where spaces go at end or beginning):

                2.
                find: 'oci_parse(^$conn, ^(^$[a-zA-Z0-9_]+^));'
                replace: 'oci_parse(^1, $conn);^p$r = oci_execute(^1);'

                3.
                find: ' or mysql_error_report(^$*);'
                replace: ';'

                12
                Basic UserBasic User
                12

                  Mar 25, 2012#8

                  Hello!

                  I suspect/hope that the answer to my question will be relatively straightforward. I have been trawling around for a way to force text between small caps tags to uppercase, e.g.:

                  <span class="font2" style="font-variant:small-caps;">Sir Denis O'Grady,</span>

                  Thanks to Mofi's previous help I know how to do the search bit:

                  <span class="font2" style="font-variant:small-caps;">^(*^)</span>

                  But I cannot find how to replace the text with uppercase, ie. SIR DENIS O'GRADY,

                  Many thanks

                  6,602548
                  Grand MasterGrand Master
                  6,602548

                    Mar 26, 2012#9

                    There are two possibilitites to do this. The first one is a macro solution using command Format - To Upper Case:

                    InsertMode
                    ColumnModeOff
                    HexOff
                    UnixReOff
                    Top
                    Loop
                    Find "<span class="font2" style="font-variant:small-caps;""
                    IfFound
                    Find RegExp "
                    >*</"
                    ToUpper
                    Else
                    ExitLoop
                    EndIf
                    EndLoop


                    This macro searches within a loop for the tag of interest. If the tag is found, it selects the text on same line from > to next </ and process the To Upper Case command on this text. The advantage of this solution is that it works also for non ASCII characters like the German umlauts äöü converted to ÄÖÜ on execution.

                    The second solution is faster because it uses a single Perl regular expression Replace All command to convert a text within the tag of interest to upper case. The disadvantage of this solution is that it works only for ASCII characters a-z converted to A-Z. I have recorded this Perl regular expression Replace All to a macro as well.

                    InsertMode
                    ColumnModeOff
                    HexOff
                    PerlReOn
                    Top
                    Find RegExp "<span class="font2" style="font-variant:small-caps;">
                    (.*)</span>"
                    Replace All "<span class="font2" style="font-variant:small-caps;">
                    \U\1\E</span>"

                    12
                    Basic UserBasic User
                    12

                      Mar 26, 2012#10

                      Excellent, Mofi! - once again I am in your debt. I created the macro and it worked wonderfully. Thank you yet again.