can't get number(s)

65 views
Skip to first unread message

Dalibor Lanik

unread,
Oct 22, 2017, 10:48:48 AM10/22/17
to Android Send/Expect
I've been pulling my hair (what I have left) with this one... I get expect as I should, but I don't get whole number in result variable.

for expect, I receive : {"id":1, "result":["on", "", "100"]} where the 100 can be any number from 1 to 100. So 1 to 3 digits.

I suppose this regex should work:

expect: .*("result").*(?<sstatus>on|off).*(?<slevel>[0-9]{1,3}).*

but it doesn't. I get "ok" in 1st variable (sstatus) but I get only one digit in slevel variable even though {1,3} should mean it is 1 to 3 digits????

Please help! :)

David

unread,
Oct 22, 2017, 12:25:24 PM10/22/17
to Android Send/Expect
I don't know why, but it looks like the  .* is messing with the {1,3}.   Trying this out in online regex tester I find that adding the quotes to the expression makes it work:

.*("result").*"(on|off)".*"([0-9]{1,3})".*

Dalibor Lanik

unread,
Oct 22, 2017, 1:22:08 PM10/22/17
to Android Send/Expect
Thanx, will try
Reply all
Reply to author
Forward
0 new messages