Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    User defined language - recognize date and time stamp

    Help wanted · · · – – – · · ·
    3
    6
    426
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ninon_1977
      Ninon_1977 last edited by

      Hi there,

      I try to highlight the date and time stamp in a txt-file by applying UDL, e.g.:

      2020-03-31 09:19:44

      Unfortunately, it does not work how I want it. I can highlight all numbers, but
      in my case I only want to highlight date and time stamp.

      Does anyone has an idea?

      Thank you and best regards!

      Ekopalypse 1 Reply Last reply Reply Quote 0
      • Ekopalypse
        Ekopalypse @Ninon_1977 last edited by

        @Ninon_1977 said in User defined language - recognize date and time stamp:

        2020-03-31 09:19:44

        Maybe by defining "2020-" and "09:" as keywords with checked prefix mode?

        PeterJones 1 Reply Last reply Reply Quote 1
        • PeterJones
          PeterJones @Ekopalypse last edited by

          @Ekopalypse said in User defined language - recognize date and time stamp:

          @Ninon_1977 said in User defined language - recognize date and time stamp:

          2020-03-31 09:19:44

          Maybe by defining "2020-" and "09:" as keywords with checked prefix mode?

          Interesting idea… though I would assume, despite the OP’s lack of information, that it’s possible to have other years (if the txt file goes back more than a few months), and highly probable that it will have hours other than 09. :-)

          If this were something I were trying to solve, I’d use your EnhanceUDLLexer.py in this linked post, and define a regex similar to \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} – though the OP may have to adjust that regex, depending on whether or not smaller numbers are always zero-prefixed, or only sometimes zero-prefixed (I would hope the former, which would match my regex…)

          1 Reply Last reply Reply Quote 3
          • Ekopalypse
            Ekopalypse last edited by

            @PeterJones
            Of course, I simply assumed that the extension of years and hours could be derived from my example :-D
            But of course I understand what you mean. :-)

            1 Reply Last reply Reply Quote 1
            • Ninon_1977
              Ninon_1977 last edited by

              Hi :-)

              I guess "EnhanceUDLLexer.py " could help me, but unfortunately I am not sure how to get it running…
              I downloaded the file and renamed it to “EnhanceUDLLexer.py” - I changed this part:

              self.lexer_name = ‘dummy_Log’

              But how can I use it now?
              Thank you!

              Ekopalypse 1 Reply Last reply Reply Quote 0
              • Ekopalypse
                Ekopalypse @Ninon_1977 last edited by Ekopalypse

                @Ninon_1977

                first you have to install PythonScript plugin from PluginAdmin.
                Then click Plugins->PythonScript->New Script
                give it a meaningful name and copy the content into the newly created document.

                Then follow the instructions in the script.
                Change the lexername and the regexes in the configuration area.
                Lexername must be exactly the same as shown in the language menu
                and use the regex from @PeterJones

                Something like this

                regexes[(0, (79, 175, 239))] = (r'\d{4}-\d{2}-\d{2} \d{2}:', 0)
                

                all other regexes from the example can be commented.

                (79, 175, 239) <-- this is the rgb color

                Execute the script via Plugins->Python Script->Scripts->YOUR_SCRIPT
                (needs to be done once per npp start only)

                1 Reply Last reply Reply Quote 2
                • First post
                  Last post
                Copyright © 2014 NodeBB Forums | Contributors