var wlan = /([a-zA-Z0-9]+)\s+Scan completed :/ var current_wlan="" if (line.match("Scan completed :")) { current_wlan = (wlan.exec(line)[1]).trim(); continue; }