How can I highlight hexadecimal numbers or regular expression matches?

How can I highlight hexadecimal numbers or regular expression matches?

5
NewbieNewbie
5

    Apr 26, 2019#1

    I tried really hard to figure out how to do this and I failed. I read all the syntax highlighting documents and I edited several. I probably spent 6 hours and I failed.

    I'm working with network logs and I want to enhance their readability with some highlighting. The format of a line could be like this:

    01 2F F4 37: 87 05 02 00 AC 7E 

    At a bare minimum I want to highlight the hex bytes as a color, but I've failed - the numbers highlight but the A-F do not.

    I'd like to be able to highlight a regex like:
    ^[0-9A-F ]{11}:
    to be red, let's say, and
    (?:[0-9A-F ]{2} ?)+
    to be blue

    or
    :.+

    Ideally if I could just arbitrarily highlight matches from defined regex, I think that would give me the full power to do everything that I want.

    Please help!

    Thanks

    6,604548
    Grand MasterGrand Master
    6,604548

      Apr 26, 2019#2

      Syntax highlighting of UltraEdit is based on words and not on regular expressions. I don't know from where you have the idea that regular expression search strings can be used for syntax highlighting. Regular expression search strings in *.uew files can be used only for the function list.

      Which sequence of characters is interpreted by UltraEdit as word is defined by the line /Delimiters = which usually contains at least a normal space and a horizontal tab character. In your case I would add also the colon to list of word delimiters. The space character is always interpreted as word delimiter even on not specified on this line because the space character is the word delimiter in *.uew files. That means it is impossible to define a word consisting of a sequence of characters containing a normal space. The horizontal tab character can be interpreted as word character if not listed on line starting with /Delimiters =.

      Words starting with a digit are always syntax highlighted by UltraEdit with color and font style settings defined for color group Numbers independent on consisting only of digits or containing also other characters.

      For your example the color group Numbers syntax highlights 01 2F F4 37: 87 05 02 00 AC 7E.

      The colon must be added on a separate line to a color group to get this word consisting only of one word delimiting character syntax highlighted with the color and font style set for this color group.

      For the hexadecimal values starting with a digit A-F (case-sensitive) it is necessary to define all possible combinations as words in a color group.

      A very simple syntax highlighting wordfile based on the little information posted by you would be:

      Code: Select all

      /L20"Logs" Noquote File Extensions = LOG
      /Delimiters =      :
      /C1"Hex. numbers"
      A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
      B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
      C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
      D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
      E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
      F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
      /C2"Colon"
      :
      
      Note: On second line there is after the equal sign a space, tab, space and colon.

      The color and font style defined for color group Hex. numbers can be set identical to the settings of predefined color group Numbers.
      Best regards from an UC/UE/UES for Windows user from Austria

      5
      NewbieNewbie
      5

        Apr 28, 2019#3

        Hey Mofi,

        I added the hex as keywords and it works out.

        I thought maybe the regexes only worked for defining functions like you said but not enough experience to know.

        If I really want to selectively highlight the text I think I will try writing it up in html markup and using background text coloring tags.

        Thanks for your help!