Tapatalk

Regular expressions and highlighting

Regular expressions and highlighting

4

    Apr 27, 2006#1

    Hello.

    This is probably a very simple question but I can't seem to get what I want so I am trying here.

    I want to highlight numbers by their prefixes. For example I want to format a set of co-ordinates given as "X-***.** Y***.** Z***.**" with the X component in colour 1, the Y in colour 2, Z positive in colour 3 and Z negative in colour 4.

    I presume that a regular expression of "X([0-9]+)" would do the trick, but how do I get this into the keyword part of "wordfile.txt"?

    Thanks

    6,685587
    Grand MasterGrand Master
    6,685587

      Apr 27, 2006#2

      As very often written in the forum, regular expressions cannot be used for normal syntax highlighting words. Only the function strings are regular expressions.

      But in your case maybe the substring definition can be used. First make sure that the - and the . character are NOT listed in the line with the delimiter characters which start with /Delimiters =.

      Then use following definitions at your case-sensitive language definition:

      /C1"X component"
      ** X
      /C2"Y component"
      ** Y
      /C3"Z negative"
      ** Z-
      /C4"Z positive"
      ** Z

      It's important that "Z negative" is color 3 and "Z positive" is color 4. See the ultimate test for duplicate words macro for an explanation why the color order is important here.
      Best regards from an UC/UE/UES for Windows user from Austria

      4

        Apr 28, 2006#3

        Thanks for that Mofi. I'll try it out later this morning. I had read about the substring definition but wasn't quite sure how it would work for me. I'll also follow up "The Ultimate Test...." to understand more.

        Thanks again

        Bob

          Apr 29, 2006#4

          I have tried what Mofi suggested and it works for X, Y and Z positive values but not for the negative values. I made sure the "-" and "." were in the "\Delimiter = " string and I tried it with the delimiter string removed - no difference.

          One thing I noticed was that in the negative values, the digits before the decimal point were in in the colour set for "numbers" whilst those after the decimal point were colour as "normal" as was the minus sign.

          I have tried a few permutations on the "delimiter =" line as the way read the help file, the defaults for delimiter include "-" and "." and the characters in the delimiter string over-ride the defaults. It appears to me that I need to find a way of excluding "-" and "." from the delimiter string.
          Any ideas?

          6,685587
          Grand MasterGrand Master
          6,685587

            Apr 29, 2006#5

            Sorry, my fault. I have forgotten the word NOT in my first answer. I was quite to fast and have edited it now.

            You must have a /Delimiters = line (and not \Delimiter = as you wrote). But this line should NOT have the characters - and ..

            Add all characters here which are really word delimiters for your type of file. A space and a tab should be always added to the list of delimiters. Make sure that the space and the tab still exist after saving the wordfile if you add it at the end of this line which you should not do. You could have the option Trim trailing spaces on file save checked in the configuration dialog. Example:

            /Delimiters = ~ ,TAB HERE!

            Best you add all characters lower decimal 128 which are not part of a word or never exist in the file.
            Best regards from an UC/UE/UES for Windows user from Austria

            4

              May 02, 2006#6

              That works. Thanks Mofi