I am having this simple script:
#!/usr/bin/expect -f
set values "#host=CE101 #host=CE102"
set found [regexp {[A-Z]{1,2}\d{2,3}} $values CE CE1]
if {$found == 1} {
puts "px is $CE"
puts "vpx is $CE1"
} else {
puts "\nfailed to match anything from\r\n$values"
}
puts $found
So my problem is that regexp is passing only the first found result to a variable and the second one is not being passed. I am sure that is the problem because of adding -all to regexp is returning 2 so I am sure that its matching both values, but I don't know why it's passing only the first matched, also I deleted "#host=CE101 and it successfully matches CE102.