Xerox printers and HTTP binding with REGEX help

I have several printers here at work I would like to get the status of currently I am using

String Jerry_Printer_1 	"Jerry's Printer [%s]"	<_7100n>	(Printer) { http="<[*?Office','(.*?)',.*)]"}
String ATAL_Printer_1 	"ATAL Printer [%s]"	<_7100n>	(Printer) { http="<[*?Labs','(.*?)',.*)]"}

but this only tells me if it needs to be replaced soon and not what needs to be replaced.

There is another lineset in the same page that tells all the pertenent info but I do not know how to extract the data from it for openhab.

var spcs=['ATAL Phaser 7100N',[''],'ATA Labs','Toner cartridge needs to be replaced soon.','w'];
var lRef='Refresh';
var lRbt='Reboot Machine';
var cfmRbt='Do you want to reboot?';
var crNote='XEROX&reg; and the sphere of connectivity design are trademarks of<BR>Xerox Corporation in the US and/or other countries.';
var artinfo=[1,[1,'093-409','The Cyan Toner [C] is low. Cartridge needs to be replaced soon. Order a new Cyan Toner [C] Cartridge. Printing can continue.',1],[1,'093-406','The Black Toner [K] Cartridge needs to be replaced soon. Order a new Black Toner [K] Cartridge. Printing can continue.',1],[1,'093-408','The Magenta Toner [M] Cartridge needs to be replaced soon. Order a new Magenta Toner [M] Cartridge but do not replace until you are instructed to. Printing can continue.',1]];

can anyone help I would like to parse the info after var artinfo=

I’ll post this here as I find it is a wonderful tool to develop Regex like this. There is an online Regex Tester (probably more than one actually) where you can paste in your source string and it will show you what parts of the string is matched as you type in the Regex.

The challenge you will have is that you have multiple parts of a complex String to match. Personally I would load the whole thing into an Item and parse out the parts in a rule. Just set up a Regex to grab the artinfo line into an Item and a rule to parse that Item’s value into another Item you use for display

rule "Parse artinfo"
    Item ArtInfo received update
    val StringBuilder str = new StringBuilder
    val parts = ArtInfo.state.toString.split(',')
    parts.forEach(s | if(s.startsWith("'The ")) str.append(s.replace("'", "") + " "))

NOTE: I just typed in the above. There is almost certainly a typo in there.

The rules engine does not play nice with the ’ character and interprets it in weird ways

I ended up going a different route. Instead of using the HTTP page info I enabled the SNMP binding and used that for reading the toner levels of all the printers here at my work. I’ll start a new thread with my findings on that.

I look forward to it. I’ve been toying with the idea of setting up SNMP monitoring on my home network as phase 1 of beefing up my LAN security.