This page last changed on Feb 03, 2014 by istian.

I am pulling a sensor value from EmonCMS with an
url http://emoncms.org/feed/value.json?id=31010&apikey=xxxxx9b9bb610b7xxxxxc85c79cxxxxx
I am receiving the value fine but the value is listed "6.5", and I would like them to
show without the "" and only show 6.5. These are temperature values, showing them inside this "" is not very nice.

Anyone know how to remove the "" signs and leave me with only the numbers?

To get rid of quotes, do use Regular Expression:

[\w\s]{1,}

Posted by pz1 at Feb 04, 2014 07:28

Thanks Pieter That did the trick!!
However, my decimals are no longer there.... Do you know what to write to also keep the decimals?

Also, I have an account set up with EmonCMS, do you know how to find the a direct URL to the graph on my dashboard.

I know how to get the dashboard URL, but on the iPhone the dashboard view is far from optimal (does not fit the screen size well).
Any ideas?

Posted by istian at Feb 04, 2014 08:52

Sorry, I focussed on the "
Try this.

[0-9]{0,}[.]{0,1}[0-9]{0,1}

If you want to retain two numbers after the decimal point change the value between the last curly brackets in 0,2

Posted by pz1 at Feb 04, 2014 09:40

However, my decimals are no longer there.... Do you know what to write to also keep the decimals?

[\d\.]+

Also, I have an account set up with EmonCMS, do you know how to find the a direct URL to the graph on my dashboard.

Vis -> 1. Select, 2. set options, 3. View -> 'Embed in your website' contents there is src="http://...." tag.

Posted by aktur at Feb 04, 2014 09:48

Hi Michal,

Your advice was very helpful, thank you.
I am using the values I collect from EmonCMS to show max and minimums temperature outside.
The expression "[\d\.]+" helps for the max temperature (since this is a positive value) but not for the minimums temperature, this because the value is negative -. When using [\d\.]+ it the value shows only the absolute value and not the negative sign -. So by using the expression I have no sign indicating if the temperature is below zero or not.
I have tried the following expression -[\d\.]+ and this works, however if the temperature becomes positive, the expression fails, and the value is not shown at all.

I need an expression that does the same as this [\d\.]+ but however takes into consideration that the value can be either positive or negative.
Any idea?

Posted by istian at Feb 04, 2014 18:36

I advise you to read some text about regex, you would avoid many confusions. Anyway, the regex should be:

-?[\d\.]+
Posted by aktur at Feb 04, 2014 19:35

Thanks Michal
I am new to regex and found some material earlier today, but I could not figure out how to solve it, and
it looks like I wasn't too far off, only missing the "?"

Since I will be polling more date from EmonCMS in the future I clearly see that regex knowledge is
a must.

Thanks again Michal

Posted by istian at Feb 04, 2014 20:21
Document generated by Confluence on Jun 05, 2016 09:36