Ad Widget

Collapse

How to convert a string to number (unsigned) by preprocessing?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cesarsj
    Senior Member
    • Dec 2018
    • 154

    #1

    How to convert a string to number (unsigned) by preprocessing?

    For example, I want to convert 'abc: 12345' to number '12345'

    I tried with:

    1 step: \nabc: (.*)
    2 step: Regular expression, parameter '\D+' and Output '/1'

    But the exit resulted in nothing.
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    Name: Regular expression
    Parameter1: abc: ([0-9].+)
    Parameter2: \1

    Comment

    • cesarsj
      Senior Member
      • Dec 2018
      • 154

      #3
      It hasn't worked yet, the error below appears. 'abc' was a way of simplifying, the correct one would be the line below Timestamp, where I left your suggestion, with a little more detail: '\nTimestamp of last test: ([0-9].+)'. Thus the error below arose.

      Item preprocessing step #1 failed: cannot perform regular expression match: pattern does not match, type "string", value "Model Family: unknown
      Device Model: ST4000VX000-1F4168
      Serial Number: Z307EQ0C
      SMART overall-health self-assessment test result: PASSED
      User Capacity: 4,000,787,030,016
      No Error Logged: 1
      Short tests errors: 0
      Timestamp of last test: 1576232101"

      Comment

      • cesarsj
        Senior Member
        • Dec 2018
        • 154

        #4
        I did it! This worked: \ nTimestamp of last test: \ t (. *)

        Comment

        • Hamardaban
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • May 2019
          • 2713

          #5
          Try don't use \n at begin of regex. Or use ".*Timestamp of last test: ([0-9].+)"

          Comment


          • cesarsj
            cesarsj commented
            Editing a comment
            "Try don't use \n at begin of regex",
            Because?
        • Hamardaban
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • May 2019
          • 2713

          #6
          Because of the ambiguity of what line feed is used (\n matches a line-feed (newline) character (ASCII 10)) and whether it is there at all.
          At all it is difficult say something on regular expressions not possessing original(!) lines'.
          Works? that's nice...
          Last edited by Hamardaban; 13-12-2019, 16:37.

          Comment

          Working...