How could I match the following where the IP address can change:
Warning: Permanently added '100.124.61.161' (RSA) to the list of known hosts.
Thanks in advance!
How could I match the following where the IP address can change:
Warning: Permanently added '100.124.61.161' (RSA) to the list of known hosts.
Thanks in advance!
 
    
    You can try the below code, change the string to restrict only specific texts.
if($string =~ m/Warning: Permanently added '(.*?)' \(RSA\) to the list of known hosts\./)
{
   print "Match Successful, IP address: $1\n";
}
else
{
   print "String did not match\n";
}
 
    
    A general regex for the ipv4 (no port) would be
(?<!\d)(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])(?:\.(?:\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])){3}(?!\d) 
Explained
 (?<! \d )
 (?:
      \d                      # 0 - 9
   |  [1-9] \d                # 10 - 99
   |  1 \d{2}                 # 100 - 199
   |  2 [0-4] \d              # 200 - 249
   |  25 [0-5]                # 250 - 255
 )
 (?:
      \.
      (?:
           \d 
        |  [1-9] \d 
        |  1 \d{2} 
        |  2 [0-4] \d 
        |  25 [0-5] 
      )
 ){3}
 (?! \d )