Skip to main content

extract

Function extract 

Source
pub fn extract(haystack: &[u8]) -> Result<Vec<String>>
Expand description

Extract all IPv4 and IPv6 addresses from input, returning them as strings.

This is a convenience function that uses default settings (all IP types included). For more control, use ExtractorBuilder and Extractor::find_iter().

§Errors

Returns an error if the builder fails to initialize (e.g., no IP types selected).

§Example

use ip_extract::extract;

let ips = extract(b"Server at 192.168.1.1 and 2001:db8::1")?;
assert_eq!(ips, vec!["192.168.1.1", "2001:db8::1"]);