The script is supposed to get the ip address from the websites given in a txt file. The script works as supposed to up until the Match Regexp part. The Regex itself works as intended when the same code is written in Python.
*** Variables ***
${ipregex} (\d ).(\d ).(\d ).(\d )
*** Test Cases ***
Ping Test
${filep}= Get File webpages.txt
@{lines}= Split To Lines ${filep}
FOR ${line} IN @{lines}
${output}= Run ping ${line} -c 1
${result}= Get Regexp Matches ${output} ${ipregex} partial_match=true
Log ${result}
END
I Appreciate any help!
CodePudding user response:
You need to escape the backslash character with another backslash, see the documentation. this example should produce the match you are looking for:
*** Settings ***
Library String
***Variables***
${output} PING wh46.go-vip.net (192.0.66.168): 56 data bytes 64 bytes from 192.0.66.168: icmp_seq=0 ttl=54 time=26.800 ms
${ipregex} ((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}
*** Test Cases ***
test
${result}= Get Regexp Matches ${output} ${ipregex}
Log ${result}