Extract IP address

Other General Resources like icon sets, sound files etc.,

Moderator: Rathinagiri

Post Reply
User avatar
bpd2000
Posts: 963
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 135 times
Been thanked: 43 times

Extract IP address

Post by bpd2000 » Sun Aug 20, 2017 12:05 pm

Extract first single IP address from text/string
Contact me for multiple IP extract

Code: Select all

// extract first single IP address from text
// bpd2000

Function Main
      LOCAL cRegEx :="[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"
      LOCAL cText  := "Kindly note my IP Address: 192.168.1.1 "
      LOCAL nStart, nLen
         
      LOCAL cIP := HB_AtX( cRegEx, cText, .F., @nStart, @nLen ) 
      
      MSGINFO( cText,"Sample String" )
      MSGINFO( cIP, "Extracted IP is" + space(10) )
 
 RETURN
BPD
Convert Dream into Reality through HMG

Post Reply