Ad Widget

Collapse

preproccessing using regex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mellis
    Senior Member
    • Oct 2017
    • 145

    #1

    preproccessing using regex

    I need to do some preprocessing on data collected. example we want to collect ip address, ip subnet and default gateway. I found it easy to use the system.run {wmic nicconfig get ipaddress} that returns a string that contains the ipaddress. I would now like to strip off every thing except the address. I found o could do some of the with the left and right trim, but there seems to be some white spaces that prevent me from getting the ip address only. I see I can use regex but do not understand the instructions or how to use this.

    Is there some good instructions on how this works?

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

    #2
    In you case use this regex ' \D*\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\D*\s* ' (not optimal and curve) to catch IP (\1 group). If the computer has more than one address - you will receive a list of them....

    Comment

    Working...