Search for a word and highlight in red

Search for a word and highlight in red

7
NewbieNewbie
7

    Dec 02, 2005#1

    This might be really simple.

    How can I search for a word in a file and have the word highlighted in a color, like red.

    Thanks for any help in advance.
    Regards

    6,675585
    Grand MasterGrand Master
    6,675585

      Feb 25, 2006#2

      I think you want to see all words found highlighted in red in UltraEdit. Such a feature is not available in UltraEdit. What do you think about the List Lines Containing String option of the find dialog?

      Or do you edit a HTML file and you want to highlight all words found by your search string highlighted in red if viewed with a WWW browser? This could be for example realized with following regular expression in UltraEdit style:

      Find What: ^(your search string^)
      Replace With: <span style="color:red">^1</span>


      Note: I have a dirty trick to highlight all simple words or key-phrases found by a search string in UltraEdit by use of syntax highlighting. The technique used for this special highlighting is to not search for a word or phrase, but to run a Replace All and add marker characters at start and end of the found strings. But you have to run a second Replace All to remove the marker characters which are just added for highlighting the strings you searched (exactly replaced) for. Are you interested in what must be configured to use this dirty trick and how to use it?
      Best regards from an UC/UE/UES for Windows user from Austria

      7
      NewbieNewbie
      7

        Mar 06, 2006#3

        Thank you, Mofi.

        I am interesting in the syntax highlighting trick you mentioned.

        Your replies are always good.

        Regards
        David

        6,675585
        Grand MasterGrand Master
        6,675585

          Mar 06, 2006#4

          Well, before I start I will inform you, that "search for a word in a file and have the word highlighted in a color" will be available in UltraEdit v12.00. It's already available in v12.00 beta 2 for the beta testers.

          To highlight single-line phrases with the dirty trick you have to add into the wordfile for every language definition you use (/L1"C/C++", /L3"HTML", ...) the following line:

          /Marker Characters = "»«"

          You can use other characters, but these marker characters should not exist in your files anywhere.

          You also have to define this pair of marker characters in an existing or better a new color group at every language where these marker characters are specified. For example:

          /C8"Found strings"
          »«

          That's it. Now all strings in a line starting with » and ending with « will be highlighted with color 8. This method cannot be used for multi-line strings.

          For multi-line strings the alternate block comment could be used instead of marker characters. Using alternate block comment has also an additional advantage: instead of a single character to mark the start and end of the search string you can use a real string (with up to five characters) for marking the string.

          To get all found strings highlighted, you now have to run a replace instead of a find.

          Find What: your search string
          Replace With: »your search string«

          But don't forget to UNDO this replace are run again a replace - a regular expression replace - to remove all  »«.

          Find What: [»«]
          Replace With:

          Replace with nothing!
          Best regards from an UC/UE/UES for Windows user from Austria

          7
          NewbieNewbie
          7

            Mar 07, 2006#5

            Thank you Mofi.

            I am glad that this function in now included in v12.x.

            Regards
            David