Re: [Simple-evcorr-users] Capturing float point number as pass it as an arugment to Perl script
Brought to you by:
ristov
From: Yuheng Du <yu...@cl...> - 2014-08-22 07:16:06
|
Hi Risto, Thank you! This is exactly what I mean. best, Yuheng On Fri, Aug 22, 2014 at 3:13 AM, Risto Vaarandi <ris...@gm...> wrote: > 2014-08-22 6:21 GMT+03:00 Yuheng Du <yu...@cl...>: > >> Hi guys, >> >> I have a user scenario like this: >> >> I am using a perl script to do a query which takes in two arguments. The >> first argument is a string called 'deviceId', the second argument should be >> a float point number representing a sensor reading. >> >> The input of SEC is in Json format: >> >> ..... >> "deviceId" => srb_2 >> "reading0“ => 0 >> "reading1" => -2.5 >> "reading2" => 3.5 >> >> "deviceId" is captured using a Single rule, how can I efficiently >> capture the value of each "readingN" 's float number using SEC pattern? >> >> Also if what I captured is a float point, how can I pass it as an >> argument to Perl script? >> Or if what I captured is using a regex like (-*)(\d+).(\d+), how can I >> pass it as arguments to Perl script, since I might have 2 or 3 arguments? >> Can I transfer the captured digits to a float number in Perl? >> > > I am not sure I have fully understood the question, but it seems to me > that it is just a matter of writing a proper regular expression to handle > all possible float formats? For example, you can try > => (-?\d+(?:\.\d+)?)$ > which checks the format of the float and sets $1 variable, but you can > also try > => (-?[\d.]+)$ > for very crude check which just verifies that data field consists of an > optional minus, followed by a sequence of digits and dots. > > hth, > risto > > >> Thanks for help! >> >> best, >> >> Yuheng >> >> >> ------------------------------------------------------------------------------ >> Slashdot TV. >> Video for Nerds. Stuff that matters. >> http://tv.slashdot.org/ >> _______________________________________________ >> Simple-evcorr-users mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users >> >> > |