I am having some trouble with regex finding multiple matches to a single line. The code below is for Mac OS X systems, to isolate what IP printers are configured (as opposed to printing to a printer server queue or to a DNS name). The code will return all iterations of an IP, even those that don’t exists…
Q: unique values of matches (regex "([0-9]{1,3}[.]){3}[0-9]{1,3}") of lines whose (it starts with "DeviceURI lpd://") of file "/private/etc/cups/printers.conf"
A: 192.1.1.101
A: 2.1.1.101
A: 92.1.1.101
The line in the file is “DeviceURI lpd://192.1.1.101/”.
The ideal response would be 192.1.1.101, and all the other IP’s that may be listed under a DeviceURI line in the file.
What am I missing as far as how to go about just getting the IP address back from regex, instead of all of the possible matches. Is this just a regex issue or is this a bad relevance issue?
( preceding texts of firsts "/" of following texts of firsts "lpd://" of it ) of lines whose (it starts with "DeviceURI lpd://") of files "/private/etc/cups/printers.conf"
substrings between "/" of following text of first "/" of lines whose ( (it contains (regex "([0-9]{1,3}[.]){3}[0-9]") ) AND (it starts with "DeviceURI lpd://") ) of file "/private/etc/cups/printers.conf"
Of course it was literally 2 minutes after I posted that I figured it out.
We tried using the following relevance finding which machines have or not have the printer installed.
However, it is not working.
substrings between “/” of following text of first “/” of lines whose ( (it contains (regex “lpd://printserver/printername”) ) AND (it starts with “DeviceURI lpd://”) ) of file “/private/etc/cups/printers.conf”